logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ceki Gulcu <...@urbanet.ch>
Subject Re: How to create different layout/appender configuration for different classes
Date Mon, 01 Jan 2001 19:55:10 GMT
At 10:01 01.01.2001 -0800, Alex Colic wrote:
>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
># 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
># Keep one backup file
>log4j.appender.R.layout.ConversionPattern=%p %d{ISO8601} %t %c - %m%n
>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.


You can attach appenders to any category. How about:

log4j.category.circle=WARN, C
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

View raw message