Search code examples
phpsymfonymonolog

Set monolog formatter in config.yml


Is there a possibility to simply just add formatter: json on config.yml of Symfony, in order to define what formatter to use on every Monolog instance?


Solution

  • app/config/config.yml

    services:

    json:
        class: Monolog\Formatter\JsonFormatter
    

    monolog:

    handlers:
        file:
            type: stream
            level: debug
            formatter: json