I'm trying to disable WP_DEBUG_LOG if and only if debug.log exists. I'd like to hook into wp_footer and test if the file exists and if so disable my debug log. All I've found though is that WP_DEBUG_LOG is a constant and can only be changed from the wp-config.php file which is too early for my case. Is there a way to change it from a constant on install and keep it working as normal?

My only other thought is to create an option on install in the options table and just check it every time wp-config loaded to see if the value has changed but I was wanting to avoid that.

Granted I could check if the file exists before I define WP_DEBUG_LOG but somebody would have to view a page twice before debug log actually exists and is detected by the file_exists() (since it's run very early) which is not optimal.

Does anybody know of a workaround to programmatically turn off WP_DEBUG_LOG?

  • 1
    You can check or load WP_DEBUG_LOG in a mu-plugin. Debug log just loads ini_set('error_log') so you can set it that way as well instead of using a WP constant.
    – Wyck
    Aug 9, 2014 at 1:37

1 Answer 1


@Wyck was right, ( well sorta :P ) you can set error logs but

1) You need to enable debugging

2) ini_set('log_errors', 1); or 0 for false

3) You need to set a log location via ini_set('error_log, $location)

Once you have that set you can then if need be test if said file exists via $location and turn off log_errors by setting its value to 0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.