logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Pepersack <rpepers...@mdinsurance.state.md.us>
Subject Declaring a Logger in an Abstract Class
Date Thu, 15 Apr 2004 12:27:44 GMT
Hi all.

I have an abstract class that has many subclasses.  There are several options:

1.  Declare it in the abstract class using the String name of the abstract 
class.  For example:

     protected static final Logger logger = 
Logger.getLogger("org.happy.Superclass"); // Logger does not have name of 
concrete class.

2.  Declare it in the abstract class using the Class of the abstract 
class.  For example:

     protected final Logger logger = 
Logger.getLogger(getClass().getName()); // Not declared static as book 
suggests.

3.  Declare it in the subclasses using the String name of each subclass.

     protected static final Logger logger = 
Logger.getLogger("org.happy.ConcreteClass");  // Logger for each 
subclass.  Lots of loggers.

4.  Declare it in the subclasses using the Class of each subclass.

     protected final Logger logger = 
Logger.getLogger(getClass().getName()); // Not declared static as book 
suggests.

Which of the above options should I use?

Thanks,

Bob Pepersack


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


Mime
View raw message