Seldaek / monolog

Sends your logs to files, sockets, inboxes, databases and various web services
https://seldaek.github.io/monolog/
MIT License
21.04k stars 1.9k forks source link

Normalize call normalizeRecord if necessary #1906

Closed johndodev closed 1 week ago

johndodev commented 3 months ago

Monolog version 3

Hello,

When you format a logRecord with JsonFormater::format(), it calls:

As a result, we get a nicely formatted record, including any exception data, if present.

However, when we try to format an array of records using JsonFormater::formatBatch() :

We lose the exception data.

As I understand, formatBatch is a way to format array of records in an optimized way if possible, with the output being the same as formatting each record individually in a foreach.

If this is the case, it may be a bug, and this PR fixes it for me. I don't know if this issue affects anything other than exception data, but it was this specific case that led me to discover the problem. For more context, I was writing a custom Handler, where I call this->getFormatter()->formatBatch($records); in handleBatch().