My WordPress error log is going to /var/log/php-fpm/www-error.log. That's not where I want it. In fact, it took me too long to figure that out. (I'm new to WP and PHP).

I've tried to redirect it with the following in my wp-config.php

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', '/var/www/html/wordpress/wp-content/wp-errors.log' ); 
error_log("hello from wp-config\n");

but it has no effect. This code is placed before/above the "stop editing" warning. I've tried other log file locations like /tmp, still, my WP_DEBUG_LOG setting is ignored. I do receive the "hello" message that I wrote - it's just in the wrong file.

I can successfully write to other locations using the form of error_log() that takes a path, like error_log('hello', 3, '/tmp/mylog.log').

ini_get('error_log') returns the path that is being used.

My php.ini does not specify a log location.

It's not a file permissions problem.

I'm self-hosting WP 5.5.1 on AWS Linux 2 (like Centos 7), with PHP 7.2.24


Update Oct 12: I learned that php-fpm is capturing the output, and that php-fpm can be configured to change this behavior. I was not able to get what I want, and I'm not motivated to continue this effort, but others with the same problem may want to look at these settings in /etc/php-fpm.d/www.conf

php_flag[display_errors] = ?? 
catch_workers_output = ??
php_admin_value[error_log] = ??

see also https://stackoverflow.com/questions/8677493/php-fpm-doesnt-write-to-error-log

  • You wouldn't be able to error_log() immediately after the define() like that in wp-config: the error path isn't copied into ini_set( 'error_log', ... ) until a few dozen lines into wp-settings, when wp_debug_data is called. But an error_log from a plugin or theme should work?
    – Rup
    Commented Sep 9, 2020 at 16:01
  • @Rup, the problem continues in a function in my child theme. Commented Sep 9, 2020 at 21:40

1 Answer 1


A couple of educated guesses:

  1. Is there a setting in Apache that circumvents your path in WP_DEBUG_LOG?
  2. Did you check the Apache error logs for permission issues?
  • It's definitely not a permission issue because I can write to the desired folder using error_log('hello', 3, '/desiredfolder/mylog.log') . There's nothing interesting in the apache error log. Also, using ini_get('error_log') , I've confirmed that log is still set to the undesired location, not the location set with WP_DEBUG_LOG. I've gotten that confirmation from a function called in my child theme, so (addressing the comment of @Rup), it doesn't seem to be a matter of delayed config of that setting. Unless I have to delay even more. Commented Sep 9, 2020 at 21:38
  • Regarding an Apache setting, I checked /etc/httpd/conf/httpd.conf and found nothing. Commented Sep 9, 2020 at 21:44

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.