如何在cakephp应用程序中将日志添加到自定义文件?

时间:2019-01-14 08:08:42

标签: php logging cakephp-3.0

我正在尝试将Webhook响应记录到自定义日志文件custom.log中,该文件保存在config / logs / custom.log路径中。我可以通过

轻松将webhook登录到同一目录中的debug.log文件。
Log::debug('my desired logs)

如何在custom.log文件中记录相同的日志。谢谢

1 个答案:

答案 0 :(得分:0)

// Configure logs/custom.log to receive all levels, but only
// those with `custom` scope.
Log::config('custom', [
    'className' => 'File',
    'path' => LOGS,
    'levels' => [],
    'scopes' => ['custom'],
    'file' => 'custom.log',
]);

Log::debug('this gets written only to custom.log', ['scope' => ['custom']]);