logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kram <mark.macum...@gmail.com>
Subject Custom Parser to handle special properties
Date Thu, 07 Aug 2008 23:44:40 GMT

Hello all,

I am using Log4J 1.2.15, and I have the need to output a special, custom,
pattern to my appenders. I have looked up at the samples and googled around
and I sort of have it working, however, when I try to add my custom pattern
property "instanceId" to the NT Logger, I get a NPE.

My properties file is like this:

log4j.rootLogger=WARN, stdout, rfa, nta

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.rfa=org.apache.log4j.RollingFileAppender
log4j.appender.nta=org.apache.log4j.nt.NTEventLogAppender

log4j.appender.stdout.layout=com.mypackage.CUSTPatternLayout
log4j.appender.stdout.layout.instanceId=PC1
log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} %G [%t] %-5p %c -
%m%n

log4j.appender.rfa.layout=com.mypackage.CUSTPatternLayout
log4j.appender.rfa.layout.instanceId=PC1
log4j.appender.rfa.layout.ConversionPattern=%d{ISO8601} %G [%t] %-5p %c -
%m%n

log4j.appender.nta.layout=com.mypackage.CUSTPatternLayout
log4j.appender.nta.layout.instanceId=PC1
log4j.appender.nta.layout.ConversionPattern=%d{ISO8601} %G [%t] %-5p %c -
%m%n

The actual NPE comes from the nta.layout.instanceId, when I remove it, it
all works fine. I have debugged the code for the CUSTPatternLayout class,
and I got a bit confused as to how it all works. And that is where you guys
come in!

I am confused as to how to the instances work, when I do something like
this:

private final Logger logger = Logger.getLogger(MyClass.class);

Is there an instance created of CUSTPatternLayout for the layout property of
each appender? If so, can I get each appender to share the same instance of
CUSTPatternLayout?

like:
log4j.appender.layout=com.mypackage.CUSTPatternLayout ???

I am a bit confused about it all at the moment, but Im getting there...

Thanks for anyone who can help out here, it is greatly appreciated!
Mark
-- 
View this message in context: http://www.nabble.com/Custom-Parser-to-handle-special-properties-tp18882222p18882222.html
Sent from the Log4j - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
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