Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

Support for MDC when using async logger #145

Closed
tomaszdomin-arevocom opened this issue May 17, 2018 · 2 comments
Closed

Support for MDC when using async logger #145

tomaszdomin-arevocom opened this issue May 17, 2018 · 2 comments
Labels
type: bug A general bug

Comments

@tomaszdomin-arevocom
Copy link

Using log log4j 1.2.17 and logstash-gelf 1.11.2

I've configured gelf appender to work with Async appender:

	<appender name="async" class="org.apache.log4j.AsyncAppender">
		<param name="BufferSize" value="500" />
		<appender-ref ref="console" />
		<appender-ref ref="gelf" />
	</appender>
	<root>
		<priority value="info"/>
		<appender-ref ref="async" />
		<!-- for some reason gelf is not handling MDC under async appender -->
	</root>

When using such setup MDC is not passed by to gelf appender.
it works fine when I moved gelf to root section.

	<root>
		<priority value="info"/>
		<appender-ref ref="async" />
		<appender-ref ref="gelf" />
	</root>

I've tried to set on Async Appender level:
<param name="LocationInfo" value="true"/>
It did not help.

@mp911de mp911de added the type: bug A general bug label May 18, 2018
@mp911de mp911de added this to the logstash-gelf 1.11.3 milestone May 18, 2018
@mp911de
Copy link
Owner

mp911de commented May 18, 2018

Good catch. The MDC isn't fetched from the LoggingEvent but statically from the MDC class itself. This causes to return always an empty MDC.

mp911de added a commit that referenced this issue May 18, 2018
The MDC is now attempted to be looked up from the LoggingEvent to include the message context across Thread boundaries.
@mp911de
Copy link
Owner

mp911de commented May 18, 2018

That's fixed now, snapshots (1.11.3-SNAPSHOT) are deployed to oss.sonatype.org.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants