【问题标题】:How to add log to custom file in cakephp app?如何将日志添加到 cakephp 应用程序中的自定义文件?
【发布时间】:2019-01-14 08:08:41
【问题描述】:

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

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

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

【问题讨论】:

标签: php logging cakephp-3.0


【解决方案1】:
// 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']]);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-05
    • 2010-09-13
    • 1970-01-01
    • 2011-08-30
    • 1970-01-01
    相关资源
    最近更新 更多