mirror of
https://github.com/Seldaek/monolog.git
synced 2026-04-26 16:15:49 +03:00
[GH-ISSUE #1629] New lines in context data do not output valid json. (Laravel) #693
Labels
No labels
Bug
Documentation
Feature
Needs Work
Support
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/monolog#693
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @LiamKarlMitchell on GitHub (Jan 24, 2022).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/1629
Monolog version 2
Noticed when using in a Laravel project and trying to ingest logs into ELK.
Something like this:
Outputs
Expecting
Just wonder if there is a setting I can alter to make it escape the new line characters as its invalid json.
Maybe related: https://github.com/Seldaek/monolog/issues/1185
https://stackoverflow.com/questions/70840461/new-lines-in-context-data-do-not-output-valid-json
@Seldaek commented on GitHub (Mar 13, 2022):
If you need your log lines to be json, the best way is to use a JsonFormatter, then it's guaranteed json one line per log record.
If you're using a LineFormatter, by default it should have allowInlineLineBreaks set to false, which should also prevent that problem. See
github.com/Seldaek/monolog@6f233d2e2f/src/Monolog/Formatter/LineFormatter.php (L43)Maybe check your config.