I want to add a custom handler to a default monolog in Symfony 2.
In my config.yaml
file, I have:
monolog:
handlers:
main:
type: stream
path: %kernel.logs_dir%/%kernel.environment%.log
level: debug
myHandler:
type: AcmeMyBundleMonologMyCustomHandler
level: error
My class looks like below:
// AcmeMyBundleMonologMyCustomHandler
use MonologLogger;
use MonologHandlerSocketHandler;
use MonologFormatterLineFormatter;
class MyCustomHandler extends AbstractProcessingHandler
{
...
}
But even before I fill my class in I get an error:
invalid handler type "acmemybundlemonologmycustomhandler" given for handler "myHandler"
How do I add a custom handler to the default monolog without creating a new monolog service?
See Question&Answers more detail:os