[GH-ISSUE #344] JsonFormatter doesn't put new line at end of entry #116

Closed
opened 2026-03-04 02:12:19 +03:00 by kerem · 2 comments
Owner

Originally created by @xiankai on GitHub (Mar 27, 2014).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/344

I'm using the JsonFormatter in conjunction with the StreamHandler - but my log file ends up as a single giant line of JSON since I'm only adding one entry at a time and the formatter doesn't add a line break at the end as opposed to the LineFormatter.

Would it make sense to add a line break at the end or would it somehow corrupt handlers that expect strict JSON?

Originally created by @xiankai on GitHub (Mar 27, 2014). Original GitHub issue: https://github.com/Seldaek/monolog/issues/344 I'm using the JsonFormatter in conjunction with the StreamHandler - but my log file ends up as a single giant line of JSON since I'm only adding one entry at a time and the formatter doesn't add a line break at the end as opposed to the LineFormatter. Would it make sense to add a line break at the end or would it somehow corrupt handlers that expect strict JSON?
kerem 2026-03-04 02:12:19 +03:00
  • closed this issue
  • added the
    Feature
    label
Author
Owner

@Seldaek commented on GitHub (Mar 27, 2014):

I don't think it would be a problem no. We already have something to do this for batch formatting, so I think it wouldn't hurt to also do it for the single-record formatting. I don't see what could be affected, but as a safety maybe it could be added as an optional constructor argument so it's possible to disable the newline if needed.

<!-- gh-comment-id:38799558 --> @Seldaek commented on GitHub (Mar 27, 2014): I don't think it would be a problem no. We already have something to do this for batch formatting, so I think it wouldn't hurt to also do it for the single-record formatting. I don't see what could be affected, but as a safety maybe it could be added as an optional constructor argument so it's possible to disable the newline if needed.
Author
Owner

@Seldaek commented on GitHub (Apr 20, 2014):

The JsonFormatter adds a newline by default now

<!-- gh-comment-id:40898909 --> @Seldaek commented on GitHub (Apr 20, 2014): The JsonFormatter adds a newline by default now
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/monolog#116
No description provided.