Symfony and Monolog - how to make it send everything below WARNING level to stdout and everything else to stderr -


while using monolog in symfony's console commands messages being outputed stderr. how configure monolog make send below warning level stdout , else stderr?

the easies way how monolog's (symfony's actually, bridge) consolehandler works:

https://github.com/symfony/monolog-bridge/blob/master/handler/consolehandler.php

   /**      * before command executed, handler gets activated , console output      * set in order know write logs.      *      * @param consolecommandevent $event      */     public function oncommand(consolecommandevent $event)     {         $output = $event->getoutput();         if ($output instanceof consoleoutputinterface) {             $output = $output->geterroroutput();         }         $this->setoutput($output);     } 

so can extend , override behavior store both outputs , decide use here

https://github.com/symfony/monolog-bridge/blob/master/handler/consolehandler.php#l153-l160

     /**      * {@inheritdoc}      */     protected function write(array $record)     {         // @ point we've determined sure want output record, use output's own verbosity         $this->output->write((string) $record['formatted'], false, $this->output->getverbosity());     } 

for example can check $record['level'] , switch output manualy. after implement own handler can configure monolog brige configuration:

http://symfony.com/doc/current/logging/monolog_console.html

# app/config/config.yml monolog:     handlers:         console:             type: service             id: my_app.monolog.console_handler 

Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -