0

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"} []
(...)
Anna
  • 43
  • 6

1 Answers1

1

I believe you just need to level down your verbosity level

See in documentation:

# app/config/config.yml

monolog:
    handlers:
        console:
            type:   console
            verbosity_levels:
                VERBOSITY_NORMAL: NOTICE
            channels: sender
Dmitry Malyshenko
  • 3,001
  • 1
  • 12
  • 20
  • thank u for your reply.. it showed me that i should look in other handlers. I'v created new handler that put those logs to different file. – Anna Oct 12 '16 at 15:18