-
Notifications
You must be signed in to change notification settings - Fork 76
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
Add support for logging markers as tags #14
Conversation
Logback (SLF4J) and Log4j 2 support Markers, which can contain useful information. This change adds support for optionally logging these markers as tags in the created/encoded log messages. By default, this feature is disabled and can be enabled by setting the `includeMarkers` configuration setting to `true` in the Log4j 2 `EcsLayout` and Logback `EcsEncoder`. See also: * https://logging.apache.org/log4j/2.0/manual/markers.html * https://www.slf4j.org/api/org/slf4j/Marker.html
Great, thanks a lot for the contribution! I think there is also some overlap with #12 |
I think Furthermore, if we take the example from the Log4j 2 documentation about markers, one could search for all SQL queries ("SQL") or only UPDATE statements ("SQL_UPDATE") in the log messages. When using private static final Marker SQL_MARKER = MarkerManager.getMarker("SQL");
private static final Marker UPDATE_MARKER = MarkerManager.getMarker("SQL_UPDATE").setParents(SQL_MARKER);
private static final Marker QUERY_MARKER = MarkerManager.getMarker("SQL_QUERY").setParents(SQL_MARKER);
Regarding the integration tests, yes. |
+1 on using tags. I guess it then would look like: |
@ruflin Yes, correct. In case of Log4j 2 it would be |
log4j2-ecs-layout/src/main/java/co/elastic/logging/log4j2/EcsLayout.java
Outdated
Show resolved
Hide resolved
log4j2-ecs-layout/src/main/java/co/elastic/logging/log4j2/EcsLayout.java
Outdated
Show resolved
Hide resolved
log4j2-ecs-layout/src/test/java/co/elastic/logging/log4j2/Log4j2EcsLayoutIntegrationTest.java
Outdated
Show resolved
Hide resolved
@pgomulka Would mapping markers to |
@felixbarny Anything to be worried about for me because of the failed tests? |
Jenkins run the tests please |
@joschi There seem to be some failing tests: https://apm-ci.elastic.co/blue/organizations/jenkins/apm-agent-java%2Fjava-ecs-logging-mbp/detail/PR-14/7/pipeline/ |
I think this should be fine, I was aiming to refactor this way. But ES is not using markers the way they should be - we just treat this basically as a label. |
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.
As soon as the tests are green we can merge this 🙂
@felixbarny Unfortunately I'm unable to see the Jenkins build output at https://apm-ci.elastic.co/blue/organizations/jenkins/apm-agent-java%2Fjava-ecs-logging-mbp/detail/PR-14/7/pipeline/ |
This is the stack trace:
I don't know where this is coming from. Could you allow edits from maintainers? If you add |
After some playing around with the URL, I've found https://apm-ci.elastic.co/job/apm-agent-java/job/java-ecs-logging-mbp/view/change-requests/job/PR-14/7. @felixbarny I think the issue was that both Log4j 2 tests, when run in parallel, modified the same singleton LoggerContext which made at least one of them fail.
That's already enabled. At least the box is checked. |
Heh, I didn’t know they were running in parallel 😄 |
Logback (SLF4J) and Log4j 2 support Markers, which can contain useful information.
This change adds support for optionally logging these markers as tags in the created/encoded log messages.
By default, this feature is disabled and can be enabled by setting the
includeMarkers
configuration setting totrue
in the Log4j 2EcsLayout
and LogbackEcsEncoder
.See also: