I want to customize the log line format of only the errorlog channel. Is it possible to define it in the config file (config/logging.php), or i have to made a class for it as the doc says? But it shows me no hint..
Can somebody show me some example?
Many thanks in advance!
The easiest method would be passing your own format to the LineFormatter class:
[
'driver' => 'monolog',
'formatter' => Monolog\Formatter\LineFormatter::class,
'formatter_with' => [
'format' => "[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n",
],
]
You can look at the LineFormatter to see that $format is accepted in the constructor.
You can create your own class implementing the FormatterInterface and look to the ~20 other formatters as examples in the Monolog/Formatter directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With