简体   繁体   中英

Logging doesn't work in cakephp 3.3

It doesn't matter whenever I use LogTrait or just the static Log functions nothing gets outputted to the debug.log file. I can't really seem to figure out why. In bootstrap.php i see this line of code:

Log::config(Configure::consume('Log'));

This must lead to the app.php, but nothing there is configuring the debug logger. I haven't removed any code from app.php, so i don't really see how it just stops working suddenly. In the debug bar on the website itself I can see what happens in the log, but if I for example do a post request that redirect to another page I don't get see what the page logged because no changes was made to the "debug.log" file

I call the log function either by using the LogTrait in CakePHP:

// I use the 'use LogTrait;' under the class declaration, and the 'use Cake\Log\LogTrait;' at the top of the file.
$this->log('message', 'debug');

Or by calling the static function:

\Cake\Log\Log::debug('message');

Check in App.php is it your Cakephp in Debug mode

'debug' => filter_var(env('DEBUG', false), FILTER_VALIDATE_BOOLEAN),

Also check your php config with phpinfo() or in php.ini file var error_reporting

Make sure your debug level is set to 1 or 2. I was getting similar error.In my case, The default app.php log settings were not right. Update following setting and reboot your server.

'Log' => [

    'debug' => [
        'className' => \Cake\Log\Engine\ConsoleLog::class,
        'levels' => ['notice', 'info', 'debug'],
    ],
    'error' => [
        'className' => \Cake\Log\Engine\ConsoleLog::class,
        'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'],
    ],
],

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM