Reputation: 1364
We are use Monolog
for logging in our project. Judging by documentation there is no way to configure Monolog
from config file, no matter xml
or yaml
. But as far as know there is a way to do this in Symfony. Unfortunately it highly depends on other Symfony components which we cannot afford to import to out project.
So, the question is: is there any way to configure Monolog
from yaml
file without using Symfony components?
Upvotes: 3
Views: 3810
Reputation: 2823
Use yaml_parse_file to parse a yaml
file to a php nested array structure. Than use the values in this array to configure monolog.
you could use a formatter to interpret log levels
function monolog_level($value, $tag, $flags): \Monolog\Level {
return \Monolog\Level::fromName($value);
}
and attach it to !log_level
Upvotes: -1
Reputation: 217
With Symfony, you might want to use Monolog-Bundle Detailed doc is here http://symfony.com/doc/current//logging.html
Monolog-Cascade and Monolog-Bundle do essentially the same thing, Cascade being more agnostic. Nothing prevents you from using Cascade if you want even with Symfony.
I would add that Monolog Bundle uses a static mapping between configuration keys and corresponding classes for Handlers, Formatters, Processors; whereas Cascade resolves all this dynamically and does not need to be modified to support new Handlers, Formatters, Processors, etc.
[Disclaimer]: I'm the author of Monolog-Cascade
Upvotes: 1
Reputation: 468
You might give Monolog Cascade a try.
From the Readme:
Monolog Cascade is a Monolog extension that allows you to set up and configure multiple loggers and handlers from a single config file.
Upvotes: 1
Reputation: 847
Have you tried converting the XML to an array and using the loadFromExtension()
as shown in this example: http://symfony.com/doc/current/cookbook/logging/monolog_email.html - see the php tab.
Upvotes: -1