Skip to content

Instantly share code, notes, and snippets.

@nehalist
Created August 17, 2017 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nehalist/b9df22534f3b3525a50f410f3ed10284 to your computer and use it in GitHub Desktop.
Save nehalist/b9df22534f3b3525a50f410f3ed10284 to your computer and use it in GitHub Desktop.
# ...
monolog:
channels: ['user_action_db', 'customer_email_db']
handlers:
user_action_db:
channels: ['user_action_db']
type: service
id: monolog.db_handler
customer_email_db:
channels: ['customer_email_db']
type: service
id: monolog.db_handler
<?php
class DefaultController extends Controller
{
/**
* @Route("/", name="homepage")
*/
public function indexAction(Request $request)
{
$this->get('monolog.logger.user_action_db')->info('test');
// replace this example code with whatever you need
return $this->render('default/index.html.twig', [
'base_dir' => realpath($this->getParameter('kernel.project_dir')).DIRECTORY_SEPARATOR,
]);
}
}
<?php
namespace AppBundle\Util;
use Monolog\Handler\AbstractProcessingHandler;
class MonologHandler extends AbstractProcessingHandler
{
protected function write(array $record)
{
// TODO: Implement write() method.
}
}
# ...
services:
# ...
monolog.db_handler:
class: AppBundle\Util\MonologHandler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment