logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Curt Arnold <carn...@apache.org>
Subject Re: PatternLayout + MDC Problem
Date Wed, 08 Oct 2008 20:21:39 GMT

On Oct 8, 2008, at 2:41 PM, Stefan Borovac wrote:

> Hi All,
>
> I'am currently working on a simple service which connects the
> XMLSocketReceiver with a DBAppender.
>
> I'am using the latest SNAPSHOTs from either log4j, log4j-components,
> and log4j-receiver.
>
> To test the service, I connect a ConsoleAppender to a logger to track
> the transmitted packages. The ConsoleAppender is staffed with a
> PatternLayout having a ConversionPattern such that the MDC should be
> printed.
>
> But the instead of the MDC being printed I end up with a NPE. This is
> caused in the MDCPatternConverter which should be initialised with a
> key being used later to extract values from the MDC hash. But this key
> is null, causing the hash function to crash throwing a NPE.
>
> A similar setup should work in Chainsaw. Hence I assume there will  
> be a
> solution for something selfmade (or am I a bit to optimistic).
>
> Any help or guess is welcome. I honestly don't want to crawl through  
> the
> Chainsaw code.
>
>
> Cheers
>  Stefan
>

Likely you have a pattern like with a "%X" with no key name (that is  
not "%X{key}").  org.apache.log4j.EnhancedPatternConverter in the  
extras companion supports just a plain "%X" and will output all  
existing key-value pairs.  It does look like the  
org.apache.log4j.PatternLayout will NPE in that case which is not  
desirable and it would be good to enhance it to support an unqualified  
%X. 

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message