-
Notifications
You must be signed in to change notification settings - Fork 397
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
[#5389] feat(logging): add org.apache.logging.log4j:log4j-layout-template-json to support server log in json format #5388
Conversation
…n format log output
Hi @puchengy thanks a lot for your contribution. Can you please create a related issue about this, also change the PR title and description to map to the related issue? Thanks a lot. |
@jerryshao for sure, done. |
LGTM, @puchengy , could you provide an json configuration example in the PR description, then the other user could reffer to it? |
Yes, we should, @puchengy can you please update the "LICENSE.bin" for your newly added dependency, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @puchengy for your contribution.
@FANNG1 @yuqi1129 @jerryshao Thanks all. Added a json configuration in the test plan as an example. Also added dep to licensen.bin, the name of the library is obtained from https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-layout-template-json. PTAL, thanks |
…t-template-json to support server log in json format (apache#5388) ### What changes were proposed in this pull request? Add org.apache.logging.log4j:log4j-layout-template-json to support server log in json format. ### Why are the changes needed? There are use cases required server logs to be viewed from logsearch tools such as Kibana. These use cases recommends log format to be json. Based on https://logging.apache.org/log4j/2.x/manual/json-template-layout.html, `log4j-layout-template-json` is needed to enable json layout for log4j. Fix: apache#5389 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Tested locally with modified lo4j property file. ``` appender.rolling.layout.type = JsonTemplateLayout appender.rolling.layout.eventTemplate = {"instant":{"$resolver":"timestamp","pattern":{"format":"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'","timeZone":"UTC"}},"level":{"$resolver":"level","field":"name"},"thread":{"$resolver":"thread","field":"name"},"message":{"$resolver":"message","stringified":true},"exception":{"$resolver":"exception","field":"stackTrace","stackTrace":{"stringified":true}}} ``` For better usability, json can be passed in via a individual file using [eventTemplateUri](https://logging.apache.org/log4j/2.x/manual/json-template-layout.html#plugin-attr-eventTemplateUri) instead.
…t-template-json to support server log in json format (apache#5388) ### What changes were proposed in this pull request? Add org.apache.logging.log4j:log4j-layout-template-json to support server log in json format. ### Why are the changes needed? There are use cases required server logs to be viewed from logsearch tools such as Kibana. These use cases recommends log format to be json. Based on https://logging.apache.org/log4j/2.x/manual/json-template-layout.html, `log4j-layout-template-json` is needed to enable json layout for log4j. Fix: apache#5389 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Tested locally with modified lo4j property file. ``` appender.rolling.layout.type = JsonTemplateLayout appender.rolling.layout.eventTemplate = {"instant":{"$resolver":"timestamp","pattern":{"format":"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'","timeZone":"UTC"}},"level":{"$resolver":"level","field":"name"},"thread":{"$resolver":"thread","field":"name"},"message":{"$resolver":"message","stringified":true},"exception":{"$resolver":"exception","field":"stackTrace","stackTrace":{"stringified":true}}} ``` For better usability, json can be passed in via a individual file using [eventTemplateUri](https://logging.apache.org/log4j/2.x/manual/json-template-layout.html#plugin-attr-eventTemplateUri) instead.
What changes were proposed in this pull request?
Add org.apache.logging.log4j:log4j-layout-template-json to support server log in json format.
Why are the changes needed?
There are use cases required server logs to be viewed from logsearch tools such as Kibana. These use cases recommends log format to be json.
Based on https://logging.apache.org/log4j/2.x/manual/json-template-layout.html,
log4j-layout-template-json
is needed to enable json layout for log4j.Fix: #5389
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Tested locally with modified lo4j property file.
For better usability, json can be passed in via a individual file using eventTemplateUri instead.