0

I want to make one Logger class which can be use in different modules in Symfony and when logging to have different channels. Here is my configurations:

service.yaml

App\Logger\MLogger:
    arguments: ['@logger']
    tags:
        - { name: monolog.logger, channel: 'mailchimp' }

monolog.yaml - dev

monolog:
    handlers:
        main:
            type:  stream
            path:  "php://stderr"
            level: debug
            channels: ["mailchimp"]
        console:
            type:  stream
            path:  "php://stderr"
            process_psr_3_messages: false
            channels: ["!event", "!doctrine"]
        deprecation:
            type: error_log
        deprecation_filter:
            type: filter
            handler: deprecation
            max_level: info
            channels: ["php"]

With this I have the custom logger and I load it with dependency injection.

Example of method inclusion:

public function send(Request $request, MLogger $logger)

The same logger class I want to use for different module and with difference channel.

How can I configure it so the Mlogger class could be used with different channels?

  • How can I use the Custom Logger in different controllers or modules with diffrent channels? – George Plamenov Georgiev Aug 22 '19 at 18:22
  • 2
    What do you mean by *"use with different channels"*? What's the expected behavior of the logger? – Nicolai Fröhlich Aug 22 '19 at 19:38
  • Different channel by the documentation is logging like different category in the log. I want to distinguish the two logs from the modules. For example this is the documetnation https://symfony.com/doc/2.4/reference/dic_tags.html#dic-tags-monolog if I log now this will be with the channel acme from the documentation. I want to have more channels so when searching the log I can see from which service or modul is comming quicker. For example look this log https://codereviewvideos.com/blog/wp-content/uploads/2017/01/monolog-output-inside-the-symfony-profiler.png – George Plamenov Georgiev Aug 22 '19 at 20:32

0 Answers0