If you use log4j without any extras it's good practice to declare the logger as
private static final Logger myLog = Logger.getLogger( MyClass.class );
private: because every descendant in class hierarchie can have its own logger
instance (i.e. for fintuning the log levels)
static: because the logger is loaded only once (when loading the class the
first time)
final: because the logger reference does not change during the runtime of the
app
If you use a own repository selector in order to separate some logger universes
(LogManager and it's default RepositorySelector is a singleton per classloader)
then you have to consider following:
- if the class is only used in one Logger universe you can declare it like above
- if the class is used in different Logger universes, but a instance of the
class is used only in one, you omit the "static"
- if a class instance is used in different Logger universes, or a util class
with static methods, you have to get the logger instance locally in every
method.
Heri
> -----Original Message-----
> From: Konstantinos Karadamoglou [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, June 13, 2006 12:27 PM
> To: [email protected]
> Subject: [SPAM (Bayesain Analysis)] - Best practice on
> declaring Loggers
> - Bayesian Filter detected spam
>
>
> 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
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]