logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Javier Gonzalez" <jagon...@gmail.com>
Subject Re: Seperate log files for Tomcat / Java errors and application info
Date Fri, 09 Jun 2006 14:31:42 GMT
On 6/9/06, Robert Bowen <syg6@yahoo.com> wrote:
> Many thanks for the tip. I still haven't gotten around to implementing it because there
are so few examples of xml files out there (there are many more .properties examples) so I
am not sure exactly how to "attach the app appender to the highest point of your app hierachy".
Currently I attach my ASYNC appender to root like this:
> <root>
>  <appender-ref ref="ASYNC"/>
> </root>

Suppose, as I said, that all your application packages are inside the
com.robertbowen.app hierachy. (And that you defined your loggers using
the class name as logger name :)

Then, assuming you have an appender called "AppAppender", you'd do this:

<logger name="com.robertbowen.app">
  <level value="INFO"/>
  <appender-ref ref="AppAppender"/>

That way, any Logger of the com.robertbowen.app hierachy, say, the
class com.robertbowen.app.MyLogicClass will send messages up the
hierachy, and the appender AppAppender will get the log object and
write it. The log object will keep climbing the hierachy until root,
unless we disable additivity...

> ... but I am not sure how to do what you say, nor how to turn off additivity. Again,
I've seen it done with .properties but not with xml. I haven't really gotten around to playing
around with it, that being said, I just wanted to write back and say thanks, I think your
tip is what I needed to know. When I get it working I'll let you know.

For additivity, you do it like this:

<logger name="com.robertbowen.app" additivity="false">
  <appender-ref ref="AppAppender"/>

This way the log object doesn't reach the root logger, which means it
doesn't get written to the ASYNC appender.

Note, once again, that this approach assumes that you are naming your
loggers after the FQN of your classes. Something like this:

package com.robertbowen.app

public class MyClass {

       private static final Logger LOG = Logger.getLogger(MyClass.class);

       // this would also work: private Logger LOG =


Javier González Nicolini

To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

View raw message