I also created a wrapper for Category, but instead of always calling the
Category.getInstance() method, I instantiate the wrapper class and it stores
a reference to the Category object.  Then uses the reference in implementing
the various methods.  Doing it this way means that we create an object for
each Category (we only create one instance, like log4j), but we don't pass
the class everywhere.

Advantages?  Disadvantages?

-Mark

-----Original Message-----
From: Don Taylor [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 23, 2001 9:33 AM
To: LOG4J Users Mailing List
Subject: Re: log4j wrapper



--- Craig Newlander <[EMAIL PROTECTED]> wrote:
> Hello,
> 
>    I'd like to absract log4j from my appilication so I don't have to
> do a
> import org.apache.log4j.* throughout my source files and be dependant
> on the
> Category class.   What is a good method to employ here?
> 
> Craig
> 

I created a wrapper class around Category. You're going to create your
debug(), error(), fatal(), info(), and warn() methods in here. You'll
also need a fully-qualified-classname of the wrapper class. So here's
an example:

class Logger {
  private static final String FQCN = Logger.class.getName();

  public static void debug(Class c, Object message) {
    Category.getInstance(c).log(FQCN, Priority.DEBUG, message, null);
  }

  public static void debug(Class c, Object message, Throwable t) {
    Category.getInstance(c).log(FQCN, Priority.DEBUG, message, t);
  }

  /* Continue wrapping all the others... */
};

-- Don

__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to