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?