logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Javier Gonzalez" <jagon...@gmail.com>
Subject Re: Best practice on declaring Loggers
Date Tue, 13 Jun 2006 13:04:42 GMT
I usually like to declare them private static final. Private because I
don't want any other class accessing the logger, and static final to
keep it "separate" from the class instances.

The exception being when you are subclassing, then it is useful to
declare the logger on the superclass like this:

private Logger log = Logger.getLogger(getClass());

That way, if you execute an inherited method, the log appears as
coming from your own class and not from the superclass.

On 6/13/06, Konstantinos Karadamoglou <kkarad@googlemail.com> wrote:
> Hello all,
> Which is the best practice of declaring Loggers? For instance, should they
> be static, private, final? and why?
> Thank you in advance, Kostas

Javier González Nicolini

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

View raw message