-
Notifications
You must be signed in to change notification settings - Fork 5
Using ContextualLogging with GELF #49
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
Comments
Can you share a small reproducer project please? |
Here is the recreation of the problem: |
Sorry for the long delay. I ran
Then I changed this in the log4j2 config because the syntax for context map lookup was wrong in console: Index: src/main/resources/log4j2.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml
--- a/src/main/resources/log4j2.xml (revision cd29bd79158f6973bafb91db2c79e2c290ecea07)
+++ b/src/main/resources/log4j2.xml (date 1669042713667)
@@ -10,7 +10,7 @@
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout>
- <pattern>%d{HH:mm:ss.SSS} [%thread] [%vcl{requestId}] %-5level %logger{36} - %msg%n</pattern>
+ <pattern>%d{HH:mm:ss.SSS} [%thread] [$${ctx:requestId:-foobar}] %-5level %logger{36} - %msg%n</pattern>
</PatternLayout>
</Console>
@@ -40,6 +40,7 @@
</Logger>
<Root level="INFO">
<AppenderRef ref="GELF" />
+ <AppenderRef ref="Console" />
</Root>
</Loggers>
</Configuration> Then I ran the app. In dev mode, indeed the contextual data is not added to the log events (neither to the console or to GELF target). However, if I build the application and then run it:
Then the contextual data is present in both the console and GELF json message. So I suspect this is a classloading issue due to the Quarkus dev mode, unrelated to this library. |
I'm trying to use contextual logging with Graylog (GELF). The problem i'm having and can't figure it out is how to send this additional fields that I added to context logs. Logging works ok, I see logs on Graylog just no additional fields like it showed with MDC.
What I tried is to use custom ContextDataProvider with creating file under META-INF/services org.apache.logging.log4j.core.util.ContextDataProvider and inserting then io.reactiverse.contextual.logging.VertxContextDataProvider
My log4j2.xml:
<Configuration> <Appenders> <Socket name="GELF" protocol="tcp" host="my.url" port="9850"> <GelfLayout includeStackTrace="true" includeThreadContext="true" includeNullDelimiter="true" compressionType="OFF"> </GelfLayout> </Socket> </Appenders> <Loggers> <Root level="INFO"> <AppenderRef ref="GELF" /> </Root> </Loggers> </Configuration>
How much I tried to debug it seems log4j doesen't pickup this VertxContextDataProvider, could I miss something when creating this file? Is type wrong or what it could be?
The text was updated successfully, but these errors were encountered: