admin管理员组

文章数量:1122846

It's the first I have seen this. In a project I'm working on, I tried to switch on the debug mode for wordpress to see logs. Even if I activate the debug_log in wp-config.php, debug.log file is never created in /htdocs/wp-content/

wp-config.php

define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);

@ini_set('display_errors',0);

define('SCRIPT_DEBUG', true);

wp-content dir rights

load.php

if ( WP_DEBUG_LOG ) {
    ini_set( 'log_errors', 1 );
    var_dump( WP_CONTENT_DIR . '/debug.log' );
    // display correctly this => "/htdocs/wp-content/debug.log";
    ini_set( 'error_log', WP_CONTENT_DIR . '/debug.log' );
}

It's the first I have seen this. In a project I'm working on, I tried to switch on the debug mode for wordpress to see logs. Even if I activate the debug_log in wp-config.php, debug.log file is never created in /htdocs/wp-content/

wp-config.php

define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);

@ini_set('display_errors',0);

define('SCRIPT_DEBUG', true);

wp-content dir rights

load.php

if ( WP_DEBUG_LOG ) {
    ini_set( 'log_errors', 1 );
    var_dump( WP_CONTENT_DIR . '/debug.log' );
    // display correctly this => "/htdocs/wp-content/debug.log";
    ini_set( 'error_log', WP_CONTENT_DIR . '/debug.log' );
}
Share Improve this question asked Mar 15, 2018 at 19:09 J.BizMaiJ.BizMai 9002 gold badges10 silver badges30 bronze badges 8
  • 2 The writability of that folder is server specific, and not just the chmod, but the ownership of the folder is important. Having said that it looks like you're on a VPS, why not just use the PHP error logs instead? – Tom J Nowell Commented Mar 15, 2018 at 19:27
  • @Tom J Nowell I'm using the plugin debug log to see logs in wordpress admin. I'm trying to trace with error_log() which files are really loaded in a broken project of one customer. This plugin needs this file. So... Sould I talk with my client to change wp-content rights on the server side ? – J.BizMai Commented Mar 15, 2018 at 19:35
  • hmmm that sounds like a suboptimal approach, can you not run the site locally? Then you could run it and watch the php error logs in realtime, or use a debugger – Tom J Nowell Commented Mar 15, 2018 at 19:42
  • I'm waiting for the database access to copy all data and work it on localhost. – J.BizMai Commented Mar 15, 2018 at 19:53
  • It's a very old and suboptimal way to debug things, the codex is very old, and there are far better ways to do it, especially on a local environment where you can use a real debugger. Are PHP error logs not available? All WP_DEBUG_LOG does is change where the log files location is – Tom J Nowell Commented Mar 15, 2018 at 19:54
 |  Show 3 more comments

2 Answers 2

Reset to default 11

I found the problem. In the Apache server, inside the php.ini, the variable...

track_errors = Off

To get this information, you can do in a phpfile phpinfo();. So, to write the debug log file, you need to set track_errors as 'On'.

None of the above solutions worked for me.

So I ran phpinfo() and found that error_log = /var/log/php-fpm/www-error.log on my machine and I was finally able to see the error. In my case, a script was exceeding 30 seconds allowed of execution time.

So use phpinfo() and find out where your logs are stored!

本文标签: Debuglog file is never created