You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Jacob Kjome <ho...@visi.com> on 2002/07/17 22:26:19 UTC

log4j programming question...

Hi,

I have seen some cases where loggers are defined as "public", some as
"protected", some as "private", and some as the default package level
visibility.  Along the same lines, I have seen cases where loggers are
defined as "static" and others non-static.  I have also seen some
cases where the logger is defined as "final".

What would be the "best practice" here?  Would it depend on the
application?  Is there an advantage for subclasses to have access to
the parent class logger as those defined as "public" and "protected"
would be visible to subclases?  Shouldn't subclasses be using their
own loggers?

I would think that the following would be the best practice:

final private static Logger logger = Logger.getLogger{MyClass.class.getName());


Is this the case?  I'm really just trying to get some validation here.
Are there any disadvantages to the above?

Thanks,

Jake

  

-- 
Best regards,
 Jacob                          mailto:hoju@visi.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: log4j programming question...

Posted by Jacob Kjome <ho...@visi.com>.
Can someone please comment on my question below?

thanks,

Jake

Wednesday, July 17, 2002, 3:26:19 PM, you wrote:

JK> Hi,

JK> I have seen some cases where loggers are defined as "public", some as
JK> "protected", some as "private", and some as the default package level
JK> visibility.  Along the same lines, I have seen cases where loggers are
JK> defined as "static" and others non-static.  I have also seen some
JK> cases where the logger is defined as "final".

JK> What would be the "best practice" here?  Would it depend on the
JK> application?  Is there an advantage for subclasses to have access to
JK> the parent class logger as those defined as "public" and "protected"
JK> would be visible to subclases?  Shouldn't subclasses be using their
JK> own loggers?

JK> I would think that the following would be the best practice:

JK> final private static Logger logger = Logger.getLogger{MyClass.class.getName());


JK> Is this the case?  I'm really just trying to get some validation here.
JK> Are there any disadvantages to the above?

JK> Thanks,

JK> Jake

  




-- 
Best regards,
 Jacob                            mailto:hoju@visi.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>