In fact, this is how we started out, just extending Category. But then you
end up importing the log4j classes that are used as parameters to the
Category methods, and the abstraction/wrapping is not complete.
In the (unlikely) event we replace log4j in the future, all we have to do is
rework our wrapper class. None of the code that uses the wrapper has to
change at all. Of course, because we map to the log4j methods/functionality
so closely, any replacement will need to have very similar functionality.
We are also going to wrap NDC or add the functionality to the wrapper class
as static methods. Other useful functionality will be added in simlar ways,
exposing the functionality without exposing the specific functionality.
Of course, we still use all the log4j configuration and appenders on the
back end. It is just the "front-end" wrapper that hides the implementation.
-Mark
-----Original Message-----
From: Nicolas [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 23, 2001 10:34 AM
To: LOG4J Users Mailing List
Subject: Re: log4j wrapper
Why don't you just extend org.apache.log4j.Category? The FQCN would be one
of
yours, and you would not have to implement any methods.
Also, in our application, we use a CategoryFactory.getInstance(Class class)
which returns AppServerCategory.getInstance(class.getName()).
Nicolas
On Thursday 23 August 2001 13:22, you 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]
---------------------------------------------------------------------
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]