logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Henriksen Niels Kristoffer <ni...@wmdata.com>
Subject RE: Log4J design question: this.getClass() in super class
Date Wed, 23 Oct 2002 07:46:57 GMT
Hi Scott and everyone,

>From my humble level of experience, I have had quite a lot of considerations
like yours.

As far as I can see, the only disadvantage you have pointed out with the
current state of affairs, is that developers must remember to do certain
things whenever they create a new class. In my project this problem can be
sovled - and has been for some developers - by setting up a class template
for the editor, that always gets the name of the class to be created, and
sets up the static logger attribute with the right name (along with a
default constructor &c). For the moment my template looks like this:

 * Copyright (c)
 * Author: $USER$
 * Date: $DATE$ - Time: $TIME$
package $PACKAGE_NAME$;

import org.apache.log4j.Logger;

public class $NAME$
  public static Logger logger = Logger.getLogger($NAME$.class.toString());

   * Default constructor
  public $NAME$()

This means that a framework for logging (and subclassing) is always in
place, when I start writing the significant parts of a class.

I have had the idea too, that it might be nice to let every *instance* have
its own Logger. But, really, I have not yet seen a case, where *intance*
information is essential to a Logger. After all, it is possible log values
of instance variables to get info about the logging instance.

This beeing said, I too think it would be nice, if we only needed to provide
one static Logger for for a "root class" and if the system could somehow let
all subclasses use this Logger in a meaningfull way. But I don't know if
this is possible, and I will leave it for others to answer.

Best regards - Niels.

To unsubscribe, e-mail:   <mailto:log4j-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-user-help@jakarta.apache.org>

View raw message