diff --git a/config/schema/monolog-1.0.xsd b/config/schema/monolog-1.0.xsd index bc9c6e55..8ffa40b6 100644 --- a/config/schema/monolog-1.0.xsd +++ b/config/schema/monolog-1.0.xsd @@ -95,6 +95,7 @@ + diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 36e8d007..784b1c53 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -661,6 +661,7 @@ public function getConfigTreeBuilder(): TreeBuilder ->end() ->scalarNode('formatter')->end() ->booleanNode('nested')->defaultFalse()->end() + ->scalarNode('handler_class')->defaultNull()->end() ->end(); $this->addGelfSection($handlerNode); diff --git a/src/DependencyInjection/MonologExtension.php b/src/DependencyInjection/MonologExtension.php index 235f3804..c41e029a 100644 --- a/src/DependencyInjection/MonologExtension.php +++ b/src/DependencyInjection/MonologExtension.php @@ -166,7 +166,15 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler return $handlerId; } - $handlerClass = $this->getHandlerClassByType($handler['type']); + if (null !== $handler['handler_class']) { + $handlerClass = $handler['handler_class']; + if (!class_exists($handlerClass)) { + throw new \RuntimeException(\sprintf('The handler class "%s" does not exist.', $handlerClass)); + } + } else { + $handlerClass = $this->getHandlerClassByType($handler['type']); + } + $definition = new Definition($handlerClass); if ($handler['include_stacktraces']) {