我想在我的monolog配置中添加一个新块,以便在单独的日志文件中包含特定包的日志。假设该频道名为purchase
config_dev.php / config_prod.php
purchase:
type: rotating_file
max_files: 10
path: %kernel.logs_dir%/purchase_%kernel.environment%.log
level: debug
channels: purchase
在开发模式下,每件事都很有效,而且这些日志都是用purchase_dev.log
编写的。但是,虽然prod模式的日志配置与dev模式相同,但我收到此错误
致命错误:未捕获异常'Symfony \ Component \ DependencyInjection \ Exception \ InvalidArgumentException',消息'服务定义“monolog.logger.purchase”不存在。“在/home/users/me/projects/ecoback/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:798
答案 0 :(得分:1)
monolog:
channels: ["purchase"]
handlers:
purchase:
type: rotating_file
max_files: 10
path: %kernel.logs_dir%/purchase_%kernel.environment%.log
level: debug
channels: ["purchase"]