Da_programmer
Da_programmer

Reputation: 177

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');

Upvotes: 0

Views: 1579

Answers (2)

Invincible
Invincible

Reputation: 1460

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'],
    ],
],

Upvotes: 0

Gfreyyy
Gfreyyy

Reputation: 49

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

Upvotes: 1

Related Questions