logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Smith <psm...@aconex.com>
Subject Re: How to use Log4J in Multiple classes? App Design?
Date Wed, 13 Jul 2005 00:02:35 GMT
I would really suggest you follow the standard pattern and have one  
Logger per class ala:

public class MyClass {

   private static final Logger LOG = Logger.getLogger(MyClass.class);


Let each class log it's own stuff.

Paul Smith

On 13/07/2005, at 9:57 AM, John Hurt wrote:

> Hi,
> My application is split up into multiple classes. If I had  
> processing in
> each class that I wanted to log, what's the best way to make a  
> reference to
> the Logger available, so that for instance they all write to the  
> same log
> file?
> Do I create an instance of the Logger class at the beginning of the  
> program
> flow, then pass that class to all the methods/classes that plan to do
> logging?
> Do I make a wrapper singleton class that has a Logger in it and all  
> code
> refers to the wrapper class?
> Do I use a base class (or interface or abstract class) that includes a
> reference to a Logger class?
> Anyone has generic examples where Logger is used in more than 1  
> class, how
> to use it gracefully? Thanks.

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

View raw message