On 6/9/06, Robert Bowen <[EMAIL PROTECTED]> 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"/>
</logger>
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"/>
</logger>
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 =
Logger.getLogger(getClass());
}
--
Javier González Nicolini
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]