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 log format #439

Open
kdeyko opened this issue May 13, 2024 · 3 comments
Open

JSON log format #439

kdeyko opened this issue May 13, 2024 · 3 comments
Labels
good first issue Good for newcomers

Comments

@kdeyko
Copy link

kdeyko commented May 13, 2024

Hi there,
Is there a way to configure the log format to be JSON? This would be useful for indexing in Elasticsearch or Datadog.
Thanks.

@winromulus
Copy link
Contributor

@kdeyko You can further configure Serilog (part of reflector) for additional sinks or formats. Have a look at Serilog json configuration and overriding configuration using environment variables in .net or using mounted files. (there is an example as part of the helm package for reflector that allows you to override the minimum logging level).

@winromulus winromulus added the good first issue Good for newcomers label Jun 10, 2024
@winromulus
Copy link
Contributor

You can also enhance reflector's Serilog configuration (and helm values) to include a file output sink as well (or even json to console) but it would have to be with a configuration flag as this is not the desired output for the majority.

@kdeyko
Copy link
Author

kdeyko commented Jun 12, 2024

Hi @winromulus, thanks for your reply!

I'm far from coding (and even more far from windows-specific coding), but after quick googling it indeed looks like we need to update the Serilog's config to enable Serilog.Formatting.Compact. Current config uses only Serilog.Sinks.Console which explicitly states:

The default output is plain text; JSON formatting can be plugged in using a package such as Serilog.Formatting.Compact.

I'll try to find some spare time to implement this, but no promises :)

A couple of other useful links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Development

No branches or pull requests

2 participants