Answer the question
In order to leave comments, you need to log in
How to change Monolog Symfony logging format?
Good day!
There was a task to write logs with changes in a simple JSON format
{"datetime":"", "data":{"email":"", "user_id":""}
. You need to write logs through Monolog (you cannot write logs without a monologue).
It is
written as $array - a simple archive that needs to be written as json
The task that I want to solve is related to the fact that you need to get a log record without extra attributes that are created by a monologue.
$this->logger->log(LogLevel::INFO, '', $array));
{"message":"","context":"{datetime":"", "data":{"email":"", "user_id":""},"level":200,"level_name":"INFO","channel":"","datetime":{"date":"","timezone_type":3,"timezone":"Europe\/Berlin"},"extra":[]}
{"datetime":"", "data":{"email":"", "user_id":""}
{"datetime":"", "data":{"email":"", "user_id":""}
Answer the question
In order to leave comments, you need to log in
You can create your own Formatter
https://github.com/Seldaek/monolog/blob/main/doc/0...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question