I have a console command as a service. I would like to log, that the command was executed in a log file called foo.log - and no other logs to be placed there.
I have almost done it, but:
in case A, I get all logs to my specyfic file (not only the one i want)
in case B, I get my specyfic log to foo.log file, but other logs i get on console screen when run consol command.
command file
class A extends command
{
(...)
protected function execute(InputInterface $input, OutputInterface $output)
{
(...)
$this->logger->info('done it');
}
}
services.yml
sender.command.fetch.and.send:
class: ReportsBundle\Command\SendReports
arguments:
- "@sender.reports.worker"
- "@logger"
tags:
- { name: console.command }
- { name: monolog.logger, channel: sender}
case A (config.yml) - when i get all logs to foo.log
monolog:
handlers:
sender:
type: stream
path: '%kernel.logs_dir%/foo.log'
channels: ~
case B (config.yml) when i get unwanted logs on screen
monolog:
channels: ['sender']
handlers:
sender:
type: stream
path: '%kernel.logs_dir%/foo.log'
channels: sender
unwanted logs:
(...)
[2016-10-11 20:48:28] doctrine.DEBUG: SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED [] []
[2016-10-11 20:48:28] doctrine.DEBUG: [] []
[2016-10-11 20:48:28] event.DEBUG: Notified event "{event}" to listener "{listener}". {"event":"console.exception","listener":"Staffim\\RollbarBundle\\EventListener\\RollbarListener::onConsoleException"} []
(...)