It really depends on the class it will be used in.  For classes which
you expect to be subclasses and where the base class should use the
derived classes category, then a protected final Logger created on
construction would be used.

If you want the base class and the derived class to have separate
logging, or rather logging for that class only, then a private static
final Logger would be used.  The private keeps other classes from using
it unintentionally and the final keeps it from being replaced (which you
almost never want to do to one of these).

The difference between package private and private could be laziness on
the coders part, or could be that the logging data is shared between
subclasses in the given package only.  I would guess it was laziness.

The usage of final is debatable, but I feel that it is useful to avoid
simple assignment errors and to have a bit more insurance that Loggers
won't get null'd or re-categorized.

In short, there are a several different ways to get a Logger because the
Logger usage varies slightly from class to class.

Use the appropriate method for the logging your class needs.

--jason


> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:jboss-
> [EMAIL PROTECTED]] On Behalf Of Christian Riege
> Sent: Friday, January 11, 2002 3:54 AM
> To: [EMAIL PROTECTED]
> Subject: [JBoss-dev] standard for obtaining an
org.jboss.logging.Logger
> instance
> 
> hi,
> 
> is there a standard way of getting the Logger instance in JBoss? the
> code is sprinkled with at least 4 different ways of doing so, i.e.
> sometimes its a private variable, sometimes its protected, sometimes
its
> on a package level access, sometimes its declared as 'final', etc ...
> how about agreeing on a standard way; that would clean up some
> confusion.
> 
> regards,
>       christian
> 
> 
> _______________________________________________
> Jboss-development mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-developmen


_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to