Simon Kitching wrote:
On Sat, 2006-04-22 at 00:23 -0400, Frank W. Zammetti wrote:
package example.foo;
public Widget {
// log has name(aka category) of example.foo.Widget
private Log log = LogFactory.getLog(Widget.class);
// special log object for issuing messages that can be
// filtered/written using rules different from the ones
// for class-specific log messages.
private Log sysAdminLog = LogFactory.getLog("sysadmin-alerts");
}
Yep, exactly what I've always done. Didn't realize I had a choice :)
Did you notice that the example created *two* loggers, one following the
normal name=classname convention, and one that doesn't?
Yep, I did... that was actually the genesis of my further question :)
When you configure logging for category "com.company.app", that
configuration applies to a category with that name, or any name that
*starts* with that prefix, unless there is a more specific config.
Gotcha, that's the part I was missing, that it's not necessarily looking
for an *exact* match, a more general one will do unless a more specific
one is found.
defaultLog=FATAL
com.company.app=DEBUG
com.company.app.unimportant=WARN
log0 = LogFactory.getLog("sysadmin-alerts");
log1 = LogFactory.getLog("org.apache.Foo");
log2 = LogFactory.getLog("com.company.app.widgets.FooWidget");
log3 = LogFactory.getLog("com.company.app.unimportant.stuff.BarWidget");
messages logged via log0 or log1:
--> no special config, so default applies.
--> only FATAL gets logged
messages logged via log2
--> nearest match is "com.company.app"
--> DEBUG and greater get logged
messages logged via log3
--> nearest match is "com.company.app.unimportant"
--> WARN and greater get logged
Excellent explanation, thank you!
SimpleLog works just like log4j or java.util.logging in this regard. See
the documenation for log4j or java.util.logging if you need more info.
Ironically, I've only ever dealt with Log4J, and only with XML
configuration, and I guess some of the concepts expressed as properties
weren't jiving.
In any case, I very much appreciate your explanation Simon, I believe
I'm all set now.
Regards,
Simon
Frank
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]