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

JSON Logging to the Console #490

Open
halprin opened this issue Jun 23, 2023 · 3 comments
Open

JSON Logging to the Console #490

halprin opened this issue Jun 23, 2023 · 3 comments
Milestone

Comments

@halprin
Copy link

halprin commented Jun 23, 2023

Please add a new writer that supports JSON output to the console instead of a file.

There is an existing json writer, but it currently only supports writing out to a file.

One can simulate JSON output to the console using the console writer, but it is easy to run into some gotchas. Given the below tinylog.properties file...

writer         = console
writer.level   = info
writer.format  = {opening-curly-bracket}"timestamp": "{date}", "level": "{level}", "message": "{message}", "thread": "{thread}"{closing-curly-bracket}
writer.charset = UTF-8
writer.stream  = out

...notice the writer.format line. It simulates JSON, but it becomes invalid JSON if the message has multiple lines (e.g. \n) or a JSON-reserved character (e.g. "). This can easily happen if there is an exception's stacktrace being logged.

So, while one can accomplish a simple simulation of JSON console logging, I believe tinylog will benefit from adding a native JSON writer to the console that fully supports JSON.

@pmwmedia pmwmedia added this to the 3.0 milestone Jun 26, 2023
@pmwmedia
Copy link
Member

This feature is already implemented in the branch of tinylog 3.

@halprin
Copy link
Author

halprin commented Jun 26, 2023

Oh, that's great to hear! I'm looking forward to version 3.

@pmwmedia
Copy link
Member

Here is a preview of the documentation of tinylog 3:
https://github.com/tinylog-org/website/blob/v3/content/documentation/configuration.md#json

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

No branches or pull requests

2 participants