Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set date format in Logger #1459

Closed
delrio-design opened this issue May 5, 2020 · 4 comments · Fixed by elecena/nano#11
Closed

Set date format in Logger #1459

delrio-design opened this issue May 5, 2020 · 4 comments · Fixed by elecena/nano#11
Labels
Milestone

Comments

@delrio-design
Copy link

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
Copy link
Owner

Seldaek commented 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.

@Seldaek Seldaek added this to the 2.x milestone May 11, 2020
@delrio-design
Copy link
Author

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.

Thanks for the consideration! You're right about the global format, that's a broad request.

@Seldaek
Copy link
Owner

Seldaek commented May 21, 2020

If you feel like sending a PR for adding this to JsonFormatter please do :)

@Shiva-Kandagatla
Copy link

I'm also stuck on the exact same problem. @delrio-design Can you please explain a bit more how you solved it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants