logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Colic <aco...@yahoo.com>
Subject Re: How to create different layout/appender configuration for different classes
Date Tue, 02 Jan 2001 00:07:52 GMT
Hi,

Thanks for the reply. That solved my problem.

Alex


--- Ceki Gulcu <cgu@urbanet.ch> wrote:
> At 10:01 01.01.2001 -0800, Alex Colic wrote:
> >Hi,
> >
> >I am trying to get a handle on creating different appender/layout 
> >configuration settings for
> >different classes. Lets say I have a main class that instantiates a couple 
> >of other classes called
> >cirlce and square. I am using the following property file for the main 
> >class and for the circle
> >and square class. I am doing this so that my project will have one 
> >configuration file common to
> >all classes. The configuration file is as follows:
> >
> >log4j.rootCategory=debug, stdout, R
> >
> >log4j.appender.stdout=org.log4j.FileAppender
> >log4j.appender.stdout.File=System.out
> >log4j.appender.stdout.layout=org.log4j.PatternLayout
> >
> ># Pattern to output the caller's file name and line number.
> >log4j.appender.stdout.layout.ConversionPattern=%5p [%t] 
> >(%F:%L)-(%M)-(%d{ISO8601}) - %m%n
> >
> >log4j.appender.R=org.log4j.RollingFileAppender
> >log4j.appender.R.File=Log4JExample.log
> >
> >log4j.appender.R.MaxFileSize=100KB
> ># Keep one backup file
> >log4j.appender.R.MaxBackupIndex=1
> >
> >log4j.appender.R.layout=org.log4j.PatternLayout
> >log4j.appender.R.layout.ConversionPattern=%p %d{ISO8601} %t %c - %m%n
> >
> >log4j.category.circle=WARN
> >log4j.category.square=ERROR
> >
> >My problem is that the way I have structured this file I only have the 
> >default rootCategory. How
> >do I sturucture this file so that there are seperate appender/layout 
> >configurations for the circle
> >and square classes. In each of these classes I use
> >
> >static Category cat = Category.getInstance(circle.class.getName());
> >
> >to instantiate the log settings.
> 
> Alex,
> 
> You can attach appenders to any category. How about:
> 
> log4j.category.circle=WARN, C
> log4j.appender.C=org.log4j.FileAppender
> log4j.appender.C.File=circle.out
> log4j.appender.C.layout=org.log4j.PatternLayout
> log4j.appender.C.layout.ConversionPattern=%p - %m%n
> ....
> 
> Similarly, you can attach an appender or appenders to the square category. 
> Does that answer the question? Ceki
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Photos - Share your holiday photos online!
http://photos.yahoo.com/

Mime
View raw message