debug - error log is going to the wrong location, WP_DEBUG_LOG is ignored

admin2025-01-07  6

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

Thoughts?

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

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

Thoughts?

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

Share Improve this question edited Oct 13, 2020 at 1:32 Elroy Flynn asked Sep 8, 2020 at 3:45 Elroy FlynnElroy Flynn 1114 bronze badges 2
  • 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. – Elroy Flynn Commented Sep 9, 2020 at 21:40
Add a comment  | 

1 Answer 1

Reset to default 0

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?
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736257393a434.html

最新回复(0)