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?
>
> I guess now I'm not quite understanding what the xxxx is then in the
> config... would I then have to use the same name in all the classes of a
> given package?
>
> In other words, like I said, I usually use the Class name paradigm as
> you describe... so, let's say I have a class com.company.app.ClassA, the
> logger would be named "ClassA" (or would it be the fully-qualified name?
> I'd still have the same question either way)... So, if in the config I
> specify:
>
> -Dorg.apache.commons.logging.simplelog.log.com.company.app=debug
>
> Will it actually do anything? I mean, won't it be looking for a logger
> with the name "com.company.app", when in fact there is none because it's
> either "com.company.app.ClassA" or simply "ClassA"? (not sure off-hand
> what you get from the .class property, fully-qualified name or not).
>
> But, if I used the same logger name, say "com.company.app" for all the
> classes in that package (can I even do that?), then it makes sense to me
> how it would work. But outside that, I guess I'm still not clear (I'm
> probably just being thick-headed in any case!)
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.
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
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.
Regards,
Simon
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]