我已经定义了一个服务来处理具有特定文本的记录(例如"匹配的路由"等等)。我已成功将这些记录写入单独的文件中。
但是,我想避免的是第二次将它们写入主日志文件。我尝试使用频道标记我的服务,并告诉主流日志忽略该频道,但我发现它不会起作用,因为从本质上讲,主流日志处理程序匹配一切
关于如何进行的任何建议?
编辑:这是我现在所拥有的:
monolog:
channels: ['noise']
handlers:
eliminate_noise_logger:
type: service
id: common.eliminate_noise_logger
channels: ['noise']
streamed:
type: stream
level: info
path: "%kernel.logs_dir%/%kernel.environment%.log"
formatter: monolog.formatter.session_request
channels: ['!noise']
console:
type: console
verbosity_levels:
VERBOSITY_NORMAL: INFO
我的服务定义:
common.eliminate_noise_logger:
class: path\to\class
arguments: ["%kernel.logs_dir%/%kernel.environment%.noise.log", ["str1", "str2", "str3"]]
tags:
- { name: monolog.logger, channel: noise }
答案 0 :(得分:0)
我就是这样做的
#config.yml
monolog:
use_microseconds: false
channels: ['secondary']
handlers:
main:
path: %kernel.logs_dir%/%kernel.language%/%kernel.environment%.log
type : fingers_crossed
action_level : error
handler : nested
channels : ['!secondary']
secondary:
type: rotating_file
max_files: 10
path: %kernel.logs_dir%/%kernel.language%/%kernel.environment%.secondary.log
level: info
channels: [secondary]