Wordpress - Is it possible to change the log file location for WP_DEBUG_LOG?
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.
It seems most of the answers here are not true anymore for WP version 5.1 and above since this change: https://make.wordpress.org/core/2019/01/23/miscellaneous-developer-focused-changes-in-5-1/
You can now define WP_DEBUG_LOG
as a path in wp-config.php
if you want to override the default wp-content/debug.log
for example:
define( 'WP_DEBUG_LOG', 'wp-content/uploads/debug.log' );
Yes, if you add some code to a plugin or a theme's functions.php like so:
if (defined('WP_DEBUG_LOG') && WP_DEBUG_LOG) {
ini_set( 'error_log', WP_CONTENT_DIR . '/debug.txt' );
}
Edit: someone else just presented me with the need to do this, so I have dropped some code into a simple plugin they can edit; it's available as a gist if anyone wants it.