Domanda

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.)

È stato utile?

Soluzione 2

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:

ini_restore('error_log');

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.

Altri suggerimenti

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a wordpress.stackexchange
scroll top