4

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?

0

1 Answer 1

3

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 problem for some long-running console applications. To make each log message appear immediately in the log targets, you should set both flushInterval and exportInterval to be 1, as shown below:

return [
    'bootstrap' => ['log'],
    'components' => [
        'log' => [
            'flushInterval' => 1,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'exportInterval' => 1,
                ],
            ],
        ],
    ],
];

Note: Frequent message flushing and exporting will degrade the performance of your application.

Sign up to request clarification or add additional context in comments.

6 Comments

after setting flushInterval and exportInterval it still doesn't show error in log
where are you checking the logs? are you using any application template, basic or advanced ?
that's weird, because even if the messages are not getting flushed in runtime/logs, you should see something in apache's php error logs
I solved the problem, directory runtime/logs was non writable, while runtime was.
my log file is empty. I dont see any error in there
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.