Home > OS >  Symfony custom channel / logger
Symfony custom channel / logger

Time:06-11

I am trying to add a simple logger channel "brp" with the following SF6.2-DEV environment:

monolog:
    channels:
        - deprecation # Deprecations are logged in the dedicated "deprecation" channel when it exists
        - brp
            type: stream
            path: "%kernel.logs_dir%/%kernel.environment%.log"
            level: info
            channels: ["!event","!doctrine","!console"]

Few things, I need this one channel to log to the database into a table I specify, also I am only interested in info, warning and errors captured in the "brp" channel.

I've managed to get access to that channel with a simplified config:

monolog:
    channels:
        - deprecation # Deprecations are logged in the dedicated "deprecation" channel when it exists
        - brp

But this logs to a file, and includes all the errors levels, and so on.

TIA

CodePudding user response:

You need to do someting like this, according to the official doc here :

monolog:
    channels: [deprecation,brp]
    handlers:
       deprecation:
          type: stream
          channels: [deprecation]
          level: error
          path: '%kernel.logs_dir%/deprecated.log' 
       brp:
          type: stream
          path: "%kernel.logs_dir%/%kernel.environment%.log"
          level: info
          channels: ["!event","!doctrine","!console"]
  • Related