Reputation: 840
Currently I've this configuration in config.yml
monolog:
handlers:
applog:
type: stream
path: /var/log/my_file.log
level: error
And in my controller, I use:
$logger = $this->get('logger');
$logger->info("test");
But, always this information "test" is writed in /var/log/prod.log
How can I change this to my_file.log?
Thanks
Upvotes: 3
Views: 2705
Reputation: 9246
Add channel
to your handler config:
monolog:
handlers:
applog:
type: stream
path: /var/log/my_file.log
level: error
channel: my_channel
Now you can get logger service for that channel:
$logger = $this->get('monolog.logger.my_channel');
Furthermore, have in mind that your logging level is error
for applog handler so $logger->info
will not be visible in file specified. However, $logger->error
will be.
Upvotes: 2