-
Notifications
You must be signed in to change notification settings - Fork 80
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
Enhancement for Compact JSON #72
Comments
I a bit confused. There is no option for pretty printing in this library. By default, its one line per event aka nd-json. |
As an example, when you have stackTraceAsArray=true and a stack trace is included in the output, multiple newline characters are included in a single event (i.e. one after each stack trace element). I was thinking that these newlines are included to make the JSON human readable. |
If you don’t like the new lines just leave the setting at the default value false. Am I missing something? |
I would only offer that the newlines are superfluous and perhaps mildly inefficient if the JSON is not read by a human consumer. And, also, perhaps it is confusing for consumers that the layout produces nd-json under some selected configuration options, but not under others. As you pointed out, the expectation of the consumer by default may be one line per event. And therefore may be surprised that this is no longer the case when you configure stackTraceAsArray=true. |
Maybe this is just a naming issue. The only reason there is a There is no use case where you would set https://github.com/elastic/ecs-logging-java/blob/master/README.md#when-stacktraceasarray-is-enabled function process(event) {
event.Put("error.stack_trace", event.Get("error.stack_trace").join("\n"));
} |
The use case would be one where the consumer software would like to persist and subsequently retrieve/custom format/present/analyze the stack in its original form (with each stack trace element as a distinctly identifiable piece of data). Yes, absolutely, you can do this as well by joining/splitting a potentially very large string on the newline character. The same end result can be achieved in the status quo implementation. However, It would be preferable to avoid a split operation on very large strings if possible. To simplify consumer adoption effort in many instances (albeit by a modest amount), giving the consumer the option to take either approach might be considered. |
The current implementation seems to yield a pretty printed output of the ECS JSON. Would it be possible to optionally configure the layout to output compact JSON?
Perhaps it would be valuable to add analogous features with the same capability and intent as those related to the "compact", "eventEol" and "endOfLine" etc settings which are available on the OEM JSONLayout.
See https://logging.apache.org/log4j/2.x/manual/layouts.html where pretty print vs compact format is discussed.
The text was updated successfully, but these errors were encountered: