欢迎,
我的任务是更改应用程序中记录器的约定。目前,记录器被配置为专用服务。我想在Symfony约定中定义记录器,并通过定义DI将记录器服务的旧名称引导到monolog.logger.channel约定中的新名称来确保向后兼容性。我有Symfony的记录器第一次做事或者有人能给我一个如何做的例子吗?提前谢谢你,我在下面用我当前的配置问候你:
应用程序/配置/ config_dev.yml:
monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
channels: ['!my_channel']
my_handler:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.my_handler.log"
level: debug
channels: ['my_channel']
console:
type: console
bubble: false
应用程序/配置/ config_prod.yml:
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
channels: ['!my_channel']
nested:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
console:
type: console
my_channel:
type: fingers_crossed
action_level: error
handler: my_channel_stream
my_channel_stream:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.my_channel.log"
level: debug
channels: ['my_channel']
的src /束/资源/配置/ logger.yml:
services:
logger:
class: Symfony\Bridge\Monolog\Logger
arguments: [logger]
calls:
- [pushHandler, ['@monolog.handler.console']]
- [pushHandler, ['@logger_handler']]
logger_handler:
class: Monolog\Handler\StreamHandler
arguments: ["%kernel.logs_dir%/%kernel.environment%.cof.log", 200]
的src /束/资源/配置/ config.yml:
monolog:
channels: ['my_channel']