Is it possible to change the log file location for WP_DEBUG_LOG?

I use WP_DEBUG_LOG in my development environment and have no issues with debug.log being in the wp-content directory.

Sometimes I turn on WP_DEBUG in production when I need to debug something, and I still want to use the log but would like to redirect it to something outside my web root. Is this possible using WP_DEBUG_LOG?

6

It turns out that all WP_DEBUG_LOG does is:

ini_set( 'log_errors', 1 );
ini_set( 'error_log', WP_CONTENT_DIR . '/debug.log' );

So, if you want to change the log location for WP_DEBUG_LOG in a plugin or theme, webaware’s answer is best. If you just want to have it changed within wp-config.php you can replace define( 'WP_DEBUG_LOG', true ); with the above 2 lines and change the log file to wherever you want.

Leave a Comment