logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bob Liu" <b...@theocc.com>
Subject config log4j customized appender
Date Thu, 03 Oct 2002 22:53:05 GMT
I just started using Log4J 1.2.6. I developed a new appender called
MyAppender extending from org.apache.log4j.AppenderSkeleton.
And I tested by doing the following in my Java code and it worked.

    MyLogger myLogger =
(MyLogger)MyLogger.getLogger(MyLogTest.class.getName());
    MyAppender c  = new MyAppender;
    myLogger.addAppender(c);
    myLogger.info("test message");

I can see the message in the destination MyAppender. (I tested on a
normal console and MQ)

Now I want to put it in the configuration properties file.

If I use log4j's appender it work as the following.

log4j.rootCategory=ERROR, dest1
log4j.appender.dest1=org.apache.log4j.ConsoleAppender
log4j.appender.dest1.layout=org.apache.log4j.PatternLayout
log4j.appender.dest1.layout.ConversionPattern=%d{MMM dd HH:MM:SS} %l %t
%c %p %m%n



But the following configuration doesn't work.

log4j.rootCategory=ERROR, dest1
log4j.appender.dest1=MyAppender
log4j.appender.dest1.layout=org.apache.log4j.PatternLayout
log4j.appender.dest1.layout.ConversionPattern=%d{MMM dd HH:MM:SS} %l %%c

%p %m%n

The error message is og4j:ERROR Could not instantiate class [MyAppender]

The interesting thing is I also developed a customized layout called
MyLayout. (extends from org.apache.log4j.Layout)
The following configuration worked.

og4j.rootCategory=ERROR, dest1
log4j.appender.dest1=org.apache.log4j.ConsoleAppender
log4j.appender.dest1.layout=MyLayout

I wonder why it could instantiate MyLayout this time.


Thanks.


Bob Liu
The OCC
bliu@theocc.com


--
To unsubscribe, e-mail:   <mailto:log4j-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-user-help@jakarta.apache.org>


Mime
View raw message