Skip to content

Instantly share code, notes, and snippets.

@mpdude
Created November 8, 2013 15:18
Show Gist options
  • Save mpdude/7372480 to your computer and use it in GitHub Desktop.
Save mpdude/7372480 to your computer and use it in GitHub Desktop.
Pushing the ConsoleHandler to the Monolog "app" logger instance in Symfony2
<?php
// ... see http://symfony.com/doc/current/components/console/introduction.html#creating-a-basic-command
namespace Acme\DemoBundle\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Bridge\Monolog\Handler\ConsoleHandler;
class GreetCommand extends Command
{
protected function configure() { ... }
protected function execute(InputInterface $input, OutputInterface $output)
{
$container->get('logger')->pushHandler(new ConsoleHandler($output));
// ...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment