logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Hughes <mhug...@feith.com>
Subject Re: Logging to separate files with different levels
Date Fri, 29 Oct 2004 15:17:23 GMT
Trond,

See the "Appenders and Layouts" section of the documentation: 
http://logging.apache.org/log4j/docs/manual.html.

You need to set the additivity property to false on the one class you 
want to only append to the specified appender.  Otherwise it will 
inherit all the appenders below it in the package level.  Hope this helps!

Trond G. Ziarkowski wrote:

> Hi all,
>
> I'm all new to log4j and all help is appreciated.
>
> I want to log everything from my app into file MyApp.log, but I also 
> want _one_ of the classes to log with a different level to file 
> MyClass.log. I have managed to do this, but output sent to file 
> MyClass.log is also sent to MyApp.log. My intention was to send output 
> from my class to MyClass.log only. Is this possible with log4j? If 
> this is possible, all hints or links to docs on how to configure this 
> is much appreciated
>
> My log4j.properties looks something like this:
>
> log4j.rootLogger=ERROR, A
> log4j.appender.A=org.apache.log4j.DailyRollingFileAppender
> log4j.appender.A.File=MyApp.log
> log4j.appender.A.DatePattern='.'yyyy-MM-dd
> log4j.appender.A.Append=true
> log4j.appender.A.layout=org.apache.log4j.PatternLayout
> log4j.appender.A.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p 
> %m%n
>
> log4j.logger.com.mycomp.myapp.util.MyClass=DEBUG, B
> log4j.appender.B=org.apache.log4j.DailyRollingFileAppender
> log4j.appender.B.File=MyClass.log
> log4j.appender.B.DatePattern='.'yyyy-MM-dd
> log4j.appender.B.Append=true
> log4j.appender.B.layout=org.apache.log4j.PatternLayout
> log4j.appender.B.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p 
> %m%n
>
>
> Thanks
>
> Trond Ziarkowski
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>


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