Only disadvantage I can see is you have a single category, where I'm
still allowing a separate category per class, meaning I can change my
logging scheme on a class-by-class basis or a package-by-package basis
or whatever. I guess my solution is more flexible. As far as
performance, getInstance() is implemented with a HashTable, so the
performance is affected by that. So my solution would be slower. Since
my application isn't speed-sensitive, within reason, I prefer the
flexibility.
One thing I haven't solved is initialization. My app is still
log4j-aware just to initialize log4j. If I placed a static initializer
in the wrapper class to initialize log4j, would that work?
-- Don
--- Mark Womack <[EMAIL PROTECTED]> wrote:
> 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]
>
__________________________________________________
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]