简体   繁体   English

记录在cakephp 3.3中不起作用

[英]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. 无论何时使用LogTrait或仅使用静态Log函数都没有关系,什么都不会输出到debug.log文件。 I can't really seem to figure out why. 我似乎无法弄清楚为什么。 In bootstrap.php i see this line of code: 在bootstrap.php中,我看到以下代码行:

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

This must lead to the app.php, but nothing there is configuring the debug logger. 这必须通向app.php,但是没有配置调试记录器。 I haven't removed any code from app.php, so i don't really see how it just stops working suddenly. 我还没有从app.php中删除任何代码,所以我真的看不到它如何突然停止工作。 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 在网站本身的调试栏中,我可以看到日志中发生的情况,但是例如,如果我执行重定向到另一个页面的发布请求,则不会看到该页面记录的内容,因为未对“调试”进行任何更改.log”文件

I call the log function either by using the LogTrait in CakePHP: 我通过在CakePHP中使用LogTrait来调用日志函数:

// 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 在调试模式下签入App.php是否是您的Cakephp

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

Also check your php config with phpinfo() or in php.ini file var error_reporting 还要使用phpinfo()或php.ini文件中的var error_reporting检查您的php配置

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. 确保将调试级别设置为1或2。我遇到了类似的错误。就我而言,默认的app.php日志设置不正确。 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'],
    ],
],

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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