commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Frank W. Zammetti" <>
Subject Re: [JCL] Logging for specific classes
Date Sat, 22 Apr 2006 04:23:01 GMT
Simon Kitching wrote:
> On Sat, 2006-04-22 at 00:00 -0400, Frank W. Zammetti wrote:
>> Ah, ok, so then a logger is named after the package of the class it is 
>> defined in?  If xxxx is the name of the logger, as the docs say, that 
>> would make sense (and that would also be the missing piece of the puzzle 
>> I needed to understand that, because I had read those docs before).
> No, a logger can be named anything at all.
> As a convenience, a Class can be passed in which case the name =
> class.getName(). Log objects don't have to have names which match the
> class they are used by, but it's a very common convention.

I didn't realize that, I thought it was a requirement.

> In 99% of cases, when loggers are created they are created by passing a
> Class object, ie have name of the class that created them.
> package;
> public Widget {
>   // log has name(aka category) of
>   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 :)

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

Will it actually do anything?  I mean, won't it be looking for a logger 
with the name "", when in fact there is none because it's 
either "" 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 "" 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!)

Thanks again Simon!

> Regards,
> Simon


> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
AIM: fzammetti
Yahoo: fzammetti
Java Web Parts -
Supplying the wheel, so you don't have to reinvent it!

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message