[英]Logging doesn't work in cakephp 3.3
無論何時使用LogTrait或僅使用靜態Log函數都沒有關系,什么都不會輸出到debug.log文件。 我似乎無法弄清楚為什么。 在bootstrap.php中,我看到以下代碼行:
Log::config(Configure::consume('Log'));
這必須通向app.php,但是沒有配置調試記錄器。 我還沒有從app.php中刪除任何代碼,所以我真的看不到它如何突然停止工作。 在網站本身的調試欄中,我可以看到日志中發生的情況,但是例如,如果我執行重定向到另一個頁面的發布請求,則不會看到該頁面記錄的內容,因為未對“調試”進行任何更改.log”文件
我通過在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');
或通過調用靜態函數:
\Cake\Log\Log::debug('message');
在調試模式下簽入App.php是否是您的Cakephp
'debug' => filter_var(env('DEBUG', false), FILTER_VALIDATE_BOOLEAN),
還要使用phpinfo()或php.ini文件中的var error_reporting檢查您的php配置
確保將調試級別設置為1或2。我遇到了類似的錯誤。就我而言,默認的app.php日志設置不正確。 更新以下設置並重新啟動服務器。
'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.