Herokiller February 2016

yii2 error not in log

I'm getting Yii2

Error (#8)
An internal server error occurred.

but it can not be found in logs.

Neither in .access .error files for this apache vhost nor in apache logs

This happens on remote server and I can't reproduce it locally. Is there any other way to see what the error is aside from changing error_reporting on remote server?

Answers


Nikhil Patel February 2016

Make sure that you have specified a log target in your configuration and the log component is loaded during bootstrapping.

Example:

return [
    'bootstrap' => ['log'],

    'components' => [
        'log' => [
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
    ],
];

Also, check your exportInterval and flushInterval setting.

From the documentation:

Log messages are maintained in an array by the logger object. To limit the memory consumption by this array, the logger will flush the recorded messages to the log targets each time the array accumulates a certain number of log messages. You can customize this number by configuring the flushInterval property of the log component:

return [
    'bootstrap' => ['log'],
    'components' => [
        'log' => [
            'flushInterval' => 100,   // default is 1000
            'targets' => [...],
        ],
    ],
];

When the logger object flushes log messages to log targets, they do not get exported immediately. Instead, the message exporting only occurs when a log target accumulates certain number of the filtered messages. You can customize this number by configuring the exportInterval property of individual log targets, like the following,

[
    'class' => 'yii\log\FileTarget',
    'exportInterval' => 100,  // default is 1000
]

Because of the flushing and exporting level setting, by default when you call Yii::trace() or any other logging method, you will NOT see the log message immediately in the log targets. This could be a p

Post Status

Asked in February 2016
Viewed 3,138 times
Voted 9
Answered 1 times

Search




Leave an answer