You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Joe Collins <jo...@letsys.com> on 2004/01/16 19:12:06 UTC

creating a logging hierarchy

Hi!
 
Where do I create the hierarchy in log4j i.e. must I have a hierarchy of
class files or can I simply create loggers in the config.xml  and if so
how do I create this hierarchy within the config.xml (i.e. syntax for
detailing logger x is a parent of logger Y). If loggers are created in
the config.xml, how are they referenced in a java application?
 
This may be a stupid question but I just need to get started on this and
pointers or examples would be very much appreciated.
 
Many Thanks
 
Joe

Re: creating a logging hierarchy

Posted by Kevin Klinemeier <zi...@yahoo.com>.
Just name your loggers with a dot notation, and they will be organized
into hieararchies.  Each point will then be a 'placeholder' entry in
tree, unless you configure a logger with that name.  One recommended
usage is to log to fully-qualified-classnames.  Here's an pseudocode
example:

Myclass.doSomething() {
     Logger.getLogger(com.mycompany.myapplication.MyClass);
}

You might just start out defining an appender for your company's code,
which in this case would be the logger named "com.mycompany".  Because
of the logger names you're using, and log4J's interpretation of dots as
hierarcy, all of the classes in that package will be children of that
logger, without you having to do any more work.

I like this approach because it lets you be more specific about your
logging later, without abritrary logger names or code changes.

Hope this helps,

-Kevin Klinemeier

--- Joe Collins <jo...@letsys.com> wrote:
> Hi!
>  
> Where do I create the hierarchy in log4j i.e. must I have a hierarchy
> of
> class files or can I simply create loggers in the config.xml  and if
> so
> how do I create this hierarchy within the config.xml (i.e. syntax for
> detailing logger x is a parent of logger Y). If loggers are created
> in
> the config.xml, how are they referenced in a java application?
>  
> This may be a stupid question but I just need to get started on this
> and
> pointers or examples would be very much appreciated.
>  
> Many Thanks
>  
> Joe
> 


__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus

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