-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
LOG4J2-3138 Define a custom model for a json layout for creating custom json logs output #562
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
Conversation
Add Enhanced json layout for defined dynamic class as model of json structure Signed-off-by: arVahedi <ar.vahedi357@gmail.com>
|
Why don't you simply use `JsonTemplateLayout`?
…On Wed, 18 Aug 2021, 02:09 Alireza Vahedi ***@***.***> wrote:
Add Enhanced json layout for defined dynamic class as model of json
structure
Signed-off-by: arVahedi ***@***.***
------------------------------
You can view, comment on, or merge this pull request online at:
#562
Commit Summary
- Close jira issue LOG4J2-3138
File Changes
- *A*
log4j-layout-jackson-json/src/main/java/org/apache/logging/log4j/jackson/json/layout/EnhancedJsonJacksonFactory.java
<https://github.com/apache/logging-log4j2/pull/562/files#diff-2bb5ea46caac5348ee3004bcf6a425afcfba55dd338c4eb89b0f480a25689acc>
(23)
- *A*
log4j-layout-jackson-json/src/main/java/org/apache/logging/log4j/jackson/json/layout/EnhancedJsonLayout.java
<https://github.com/apache/logging-log4j2/pull/562/files#diff-d59581b9a099148b941846dfc3ee55b77a610ac237f6f826c49b0b1c68b60034>
(132)
- *A*
log4j-layout-jackson/src/main/java/org/apache/logging/log4j/jackson/AbstractEnhancedJacksonFactory.java
<https://github.com/apache/logging-log4j2/pull/562/files#diff-7296cf0eaee5f1fc60465c3d572e77fadbd0d232e7bc68cc7c6bd4086818dabe>
(32)
- *A*
log4j-layout-jackson/src/main/java/org/apache/logging/log4j/jackson/AbstractEnhancedJacksonLayout.java
<https://github.com/apache/logging-log4j2/pull/562/files#diff-6fe5da58aa42e680d794da05ab6a15060605387d74e2040e201cdc08aca44acd>
(240)
- *A*
log4j-layout-jackson/src/main/java/org/apache/logging/log4j/jackson/model/DefaultLogEventWrapper.java
<https://github.com/apache/logging-log4j2/pull/562/files#diff-ee680d10cee1ef0fe893037afd24134defa815e070238f7165fd57561024afc1>
(24)
- *A*
log4j-layout-jackson/src/main/java/org/apache/logging/log4j/jackson/model/JsonModelLogEventWrapper.java
<https://github.com/apache/logging-log4j2/pull/562/files#diff-8f33d792008b0a3559793b8ed9aa1d25b1e4677956067805db8155fe2f30329b>
(29)
Patch Links:
- https://github.com/apache/logging-log4j2/pull/562.patch
- https://github.com/apache/logging-log4j2/pull/562.diff
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#562>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAARTSJZVTNN2AJ7LTZC37DT5LTZBANCNFSM5CK2VPRA>
.
|
|
Couldn't you implement these using a custom |
Maybe, but it is more complex way. I amaze why we have implemented some complex approach instead of define just one model class as simplest way we can to use. |
|
I will back at my desk in a week or so, then I will be able to review this
PR. I'd appreciate holding this PR on hold until then.
Alireza, are you sure you understand Carter's suggestion right? I am
surprised at how promptly you concluded that it is not gonna work for you
given that feature is yet to be released in 2.15.0. JTL's plugin support
enables you to introduce any custom serialization logic within a method
accepting a `LogEvent` and a 'JsonWriter`. I am curious what can be more
easier and customizable than this.
…On Thu, 19 Aug 2021, 08:52 Alireza Vahedi ***@***.***> wrote:
imagine I need to log some value out of LogEvent context and based on some
logic at runtime, for example generate an activityId, digest value or
something like that at runtime.
Couldn't you implement these using a custom TemplateResolver to define
additional components?
Yes we can, but it is more complex way. I amaze why we have implemented
some complex approach instead of define just one model class as simplest
way we can to use.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#562 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAARTSLTQS6LRAPLSCCNXJ3T5SLZTANCNFSM5CK2VPRA>
.
|
|
I have just skimmed over the changes and I am totally against this PR. We already have 3 competing JSON layouts in the project: I will to close this PR and the JIRA ticket due to insufficient justification. Feel free to reopen them if you have objections. |
Add Enhanced JSON layout to define dynamic class as a model of the JSON structure.
Usage:
XML configuration:
And CustomModelLogEventWrapper class:
Signed-off-by: arVahedi ar.vahedi357@gmail.com