source

WP_DEBUG_LOG가 true로 설정되어 있으면 debug.log에 디버깅 출력이 표시되지 않습니다.이유는 무엇입니까?

itover 2023. 2. 7. 19:46
반응형

WP_DEBUG_LOG가 true로 설정되어 있으면 debug.log에 디버깅 출력이 표시되지 않습니다.이유는 무엇입니까?

개발 중인 플러그인의 WordPress를 사용하여 기본 디버깅 출력을 활성화하려고 합니다.지금까지 간신히 구했지만 리다이렉트에는 실패했어요wp-content/debug.log는 더글라스 네이너의 가이드를 대충 따라하고 있습니다.제가 한 일은 다음과 같습니다.

이 코드 조각은 의 끝에 추가했습니다.wp-config.php:

@ini_set ('display_errors', 0);
define ('WP_DEBUG', true);
define ('WP_DEBUG_DISPLAY', false);
define ('WP_DEBUG_LOG', true);

수동으로 작성했습니다.debug.log파일링하여 에 의해 접근할 수 있는지 확인합니다.www-data사용자(WordPress를 Ubuntu 12.04에서 로컬로 실행하고 있습니다):

septi@norbert:~$ sudo su www-data -c 'ls -l /usr/share/wordpress/wp-content/debug.log'
-rw-rw-r-- 1 root www-data 0 Dec  9 22:12 /usr/share/wordpress/wp-content/debug.log
septi@norbert:~$ sudo su www-data -c 'ls -l /srv/www/localhost/wp-content/debug.log'
-rw-rw-r-- 1 root www-data 0 Dec  9 22:12 /srv/www/localhost/wp-content/debug.log
septi@norbert:~$ sudo su www-data -c 'echo i can write >> /usr/share/wordpress/wp-content/debug.log'
septi@norbert:~$

플러그인의 액티베이션훅에 몇 가지 디버깅 출력 스테이트먼트와 의도적인 에러가 추가되었습니다.

include ('i fail wp');

register_activation_hook (__FILE__, 'hello_world_activate');

function hello_world_activate()
{
    error_log ('I love debug output when it works!');
}

제가 예상하는 것은 include 파일이 누락되었다는 오류 메시지입니다.debug.log"I love debug output when it works!"라는 메시지가 표시되고 페이지에는 아무것도 표시되지 않습니다.페이지 메시지에 include 파일이 누락되어 있는 것을 알 수 있습니다.debug.log단, debug 출력 메시지는 완전히 손실되지 않습니다.나는 그것을 찾았다./var/log/apache2/error.log:

[Sun Dec 09 22:58:18 2012] [error] [client 127.0.0.1] PHP Warning:  include(i fail wp): failed to open stream: No such file or directory in /usr/share/wordpress/wp-content/plugins/helloworld2085/helloworld2085.php on line 28, referer: http://localhost/wp/wp-admin/plugins.php?deactivate=true&plugin_status=all&paged=1&s=
[Sun Dec 09 22:58:18 2012] [error] [client 127.0.0.1] PHP Warning:  include(): Failed opening 'i fail wp' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /usr/share/wordpress/wp-content/plugins/helloworld2085/helloworld2085.php on line 28, referer: http://localhost/wp/wp-admin/plugins.php?deactivate=true&plugin_status=all&paged=1&s=
[Sun Dec 09 22:58:18 2012] [error] [client 127.0.0.1] I love debug output when it works!, referer: http://localhost/wp/wp-admin/plugins.php?deactivate=true&plugin_status=all&paged=1&s=
[Sun Dec 09 22:58:18 2012] [error] [client 127.0.0.1] PHP Warning:  include(i fail wp): failed to open stream: No such file or directory in /usr/share/wordpress/wp-content/plugins/helloworld2085/helloworld2085.php on line 28, referer: http://localhost/wp/wp-admin/plugins.php?deactivate=true&plugin_status=all&paged=1&s=
[Sun Dec 09 22:58:18 2012] [error] [client 127.0.0.1] PHP Warning:  include(): Failed opening 'i fail wp' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /usr/share/wordpress/wp-content/plugins/helloworld2085/helloworld2085.php on line 28, referer: http://localhost/wp/wp-admin/plugins.php?deactivate=true&plugin_status=all&paged=1&s=

내 생각엔error_log()함수는 출력에 사용할 수 없습니다.debug.log하지만 나는 올바른 길을 찾지 못했다.아, 물론 파일 경로를 하드코드해서 첨부할 수도 있지만...

Fedora 19의 Apache 2.4에서 WordPress를 실행하는 경우에도 동일한 문제가 발생했습니다.error_log()의 출력이 wp-content/debug.log가 아닌 /var/log/httpd/error_log에 착지하고 있었습니다.Httpd 프로세스는 /var/www/html/wp-content 디렉토리에 대한 쓰기 권한(+775)을 가지고 있지만 wp-content/debug.log 파일을 작성할 수 없었습니다.

my wp-config.php 디버깅 설정은 다음과 같습니다.

@ini_set(‘display_errors’,0);
define('WP_DEBUG',         true);
define('WP_DEBUG_DISPLAY', false);
define('WP_DEBUG_LOG', true);

알고 보니 진짜 원인은 SELinux였습니다.SELinux 정책을 변경하고 httpd가 다음 명령어로 wp-content에 쓸 수 있도록 했습니다.(설치를 위한 실제 명령어는 SELinux 문제 슈터를 참조하십시오.)

semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/wp-content'
restorecon -v '/var/www/html/wp-content'

이 디버깅 메시지가 wp-content/debug.log에 표시되기 시작합니다.

error_log() 함수는 웹 서버의 오류 로그(예: /var/log/syslogd/error_log)에 씁니다.필요한 것은 trigger_error입니다.

언급URL : https://stackoverflow.com/questions/13788660/with-wp-debug-log-set-to-true-no-debug-output-shows-in-debug-log-why

반응형