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

Standardize JSON output ? #504

Open
fmeriaux opened this issue Aug 30, 2023 · 3 comments
Open

Standardize JSON output ? #504

fmeriaux opened this issue Aug 30, 2023 · 3 comments

Comments

@fmeriaux
Copy link

fmeriaux commented Aug 30, 2023

There are output differences between the 2 options for logging JSON.

These differences include different property names and output type : messages vs message and list(string) vs string for example.

Sources:
https://github.com/outr/scribe/blob/master/jsonFabric/shared/src/main/scala/scribe/json/ScribeFabricJsonSupport.scala#L38
https://github.com/outr/scribe/blob/master/jsonCirce/shared/src/main/scala/scribe/json/ScribeCirceJsonSupport.scala#L23

I propose to standardize around this format (which I think is fairly common):

{
    "timestamp":"1511814391023",
    "logger":"my.demo.logger",
    "message":"Hello world!", # group all messages to one
    "level":"INFO",
    "thread":"thread-name",
    "mdc": {
        "foo":"bar"
      },
    "stack_trace" : " traces ..."
   # etc...
}

What do you think?

@darkfrog26
Copy link
Contributor

I'm not opposed to standardizing, I think that's a good plan. However, I think the messages array is useful when there are multiple messages to have a structured way to extract them back out. I'd welcome a PR to provide some standardization.

@fmeriaux
Copy link
Author

fmeriaux commented Aug 31, 2023

If I have a bit of time, I'll try to make a PR 🙂

For the message: in my experience, logging tools (which parses the json) expect a single message. I haven't yet come across a usecase where we wanted to put a list of messages for a particular log. Generally, we're going to rely on the stacktrace or the MDC if we want to get something structured out.

But if necessary, I think we can either output 2 properties (1 unique grouped string and 1 for the array), or provide options on which json formatting to choose.

@darkfrog26
Copy link
Contributor

That's reasonable. I just try to avoid data-loss as much as possible.

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

No branches or pull requests

2 participants