Skip to content

Commit d3aa3bd

Browse files
committed
Allow to autowire the default logger
1 parent 7117b9a commit d3aa3bd

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

DependencyInjection/MonologExtension.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ public function load(array $configs, ContainerBuilder $container)
5353
$loader->load('monolog.xml');
5454
$container->setAlias('logger', 'monolog.logger');
5555

56+
// always autowire the main logger, require Symfony >= 2.8
57+
if (method_exists('Symfony\Component\DependencyInjection\Definition', 'addAutowiringType')) {
58+
$container->getDefinition('monolog.logger')->addAutowiringType('Psr\Log\LoggerInterface');
59+
}
60+
5661
$handlers = array();
5762

5863
foreach ($config['handlers'] as $name => $handler) {

0 commit comments

Comments
 (0)