mirror of
https://github.com/Seldaek/monolog.git
synced 2026-04-26 08:05:53 +03:00
[GH-ISSUE #1459] Set date format in Logger #616
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#616
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 @delrio-design on GitHub (May 5, 2020).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/1459
Some background: I am using Fluent Bit as a log forwarder for a containerized PHP application with Monolog, and want to standardize date formats across my log streams.
Some formatters, such as LineFormatter and NormalizeFormatter allow this already. I am using JsonFormatter for structured logs, it inherits from NormalizeFormatter, but I don't believe I can set the date format without subclassing it and overriding the normalize method myself. I would like to be able to set the date format globally or consistently per formatter. Given that some streams require certain date formats for ingestion by third party services, it would be nice if each step from logger to handler to stream inherited the default or global date format unless explicitly set.
@Seldaek commented on GitHub (May 11, 2020):
Indeed JsonFormatter relies on jsonSerialize's implementation on
Monolog\DateTimeImmutable.I think fixing it to allow choosing a date format sounds possible and reasonable, but I am not sure about adding a default global date format option, that sounds like it's going to be a mess to handle.
@delrio-design commented on GitHub (May 18, 2020):
Thanks for the consideration! You're right about the global format, that's a broad request.
@Seldaek commented on GitHub (May 21, 2020):
If you feel like sending a PR for adding this to JsonFormatter please do :)
@Shiva-Kandagatla commented on GitHub (Sep 5, 2020):
I'm also stuck on the exact same problem. @delrio-design Can you please explain a bit more how you solved it.