I have two different instances of the same server (one for development, one for deployment), built independently but basically the same (same OS, same WordPress version, same content etc.).

However, I'm confused about the configuration: it looks to me like they're configured the same (except that the deployment server is told not to write errors/warnings to the browser).

Both configurations specify ini_set( 'error_log', '/var/log/wp-debug.log' ); and that file is indeed created by both; however, on one server anything written using error_log(...) goes to /var/log/wp-debug.log whereas on the other server, such output instead goes to /var/log/apache2/error.log (although PHP errors and warnings go to /var/log/wp-debug.log).

I've tried playing with the defined values of WP_DEBUG, WP_DEBUG_LOG and WP_DEBUG_DISPLAY as well as changing what display_errors is set to via ini_set(...) but nothing seems to make any difference.

Can I specify somewhere that I want the output of error_log(...) calls to go to one or other of these logs? (I'd like the output always to go to the Apache error.log because that extra information I want to use.)

  • 1
    Where and when are you setting your ini_set? It looks like and that second server, the ini_set is ignored (or simply not set) and error_log() is using your web servers default location.
    – bynicolas
    Commented Sep 12, 2016 at 15:48
  • Both ini_sets for log_errors are done in the same place on each server, which is in wp-includes/load.php. (And before anyone says anything... yes, I know I shouldn't modify anything inside wp-includes! Best practice aside, both should really behave the same.)
    – IpsRich
    Commented Sep 13, 2016 at 7:36
  • You are right, they should behave the same given that no other server configuration are the same. Have you double checked your htaccess file, your server-available configuration and your php.ini file for any overriding settings or misconfigurations? Other than that I don't see why it's not working the same on both machine. Did Rarst answer fix your issue? I would of suggested the same thing.
    – bynicolas
    Commented Sep 13, 2016 at 13:04
  • 1
    Ultimately, the simplest solution was to add ini_restore('error_log'); to the end of my wp-config.php file. That way, I no longer need to be naughty and change the settings in wp-includes/load.php and don't need to try to send the output to apache2's error.log: that's the default so restoring the value does the trick. Thanks for your advice!
    – IpsRich
    Commented Sep 13, 2016 at 13:56

2 Answers 2


On WP side the only handling it does is setting log to WP_CONTENT_DIR . '/debug.log' if WP_DEBUG_LOG is enabled (highly bad idea in production environment as public location). If I remember right the very early implementations of this constant allowed to customize the path, but that's no longer the case.

In my experience ini_set( 'log_errors', 1 ); ini_set( 'error_log', '/path' ) in wp-config.php should be sufficient (if you don't enable WP_DEBUG_LOG which will override it).

Your second case sounds strange. I would expect errors to go one destination or another, but not to two separate log files. It might be that something changes the configuration during runtime. It's impossible to say without hands on troubleshooting.

  • Thanks @Rarst, I'm glad you agree it's strange! I found your comment about WP_DEBUG_LOG interesting: I hadn't considered that this might be another way of configuring PHP's behaviour, I assumed they were two separate layers of configuration. I'm now wondering what would happen if I completely unset this part of the config... Would it default to going into Apache's error log instead?
    – IpsRich
    Commented Sep 13, 2016 at 7:40
  • Yes, if it's unset it should go to Apache log, see php.net/manual/en/errorfunc.configuration.php#ini.error-log
    – Rarst
    Commented Sep 13, 2016 at 7:47
  • Thanks again. Indeed it did! I still have no idea why the original configuration works for one server but not for the other but this is a good workaround.
    – IpsRich
    Commented Sep 13, 2016 at 8:08

As described elsewhere on this page, in my case the solution was simply to reset the value of PHP's error_log setting. I did this by adding to the end of my /var/www/html/wp-config.php:


One important point: I ended up putting this right at the end because it didn't seem to take effect when included just after the various define('WP_DEBUG...', ...); lines.

Thanks to Rarst and bynicolas for their advice, which helped lead me to this solution.

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.