OK. Ignoring the performance issue, this solution let me add Category
declarations to all 61 servlets in once place instead of editing all the
servlets.

John

> -----Original Message-----
> From: Ceki Gülcü [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, April 12, 2001 5:43 PM
> To: LOG4J Users Mailing List
> Subject: Re: Categories in Servlets
> 
> 
> 
> Hi John,
> 
> There is nothing special about servlets except that they get 
> reloaded if the jar file or class files change. Getting a 
> category instance is very fast. I would not waste my time 
> trying to optimize category creation. Ceki
> 
> At 17:29 12.04.2001 -0700, John Lindwall wrote:
> >I understand why the log4j docs recommend declaring the 
> Category as a static variable in a "normal" class -- this 
> reduces the overhead of creating the object to a one-time event.
> > 
> >Is this also the best approach to take in a Servlet?  We 
> have a heirarchy of servlets in our product all of which 
> descend from a base servlet class.  I figured I would reduce 
> the cost of retrofitting all of these servlets with Category 
> declarations by defining a Category in the base class and 
> initalizing it in init(), like so:
> > 
> >public class BaseServlet extends HttpServlet
> >{
> > /** The category that this class will use for logging */
> > protected static Category log = null;
> >...
> > public void init(ServletConfig config)
> >     throws ServletException
> > {
> >     super.init(config);
> > 
> >        // Initialize the logger using the subclass name as 
> the category name
> >       log = Category.getInstance(getClass().getName());
> >       ...
> > 
> >This should still be a low-cost approach since init() 
> happens once. Does this idea seem valid?
> > 
> >Thanks! 
> >----------------------------------------------------------------- 
> >John Lindwall                              
> <mailto:[EMAIL PROTECTED]>mailto:[EMAIL PROTECTED] 
> >XIFIN                                      
> <http://www.xifin.com/>http://www.xifin.com 
> >2233 Faraday Ave Ste A, Carlsbad CA 92008  (760) 804-0770 ext 16 
> >
> >This message is for the sole use of the intended 
> recipient(s) and may contain confidential and privileged 
> information. Any unauthorized review, use, disclosure or 
> distribution is prohibited. If you are not the intended 
> recipient, please contact the sender and destroy all copies 
> of the original message.
> > 
> 
> --
> Ceki Gülcü     Web: http://qos.ch 
> email: [EMAIL PROTECTED] or [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]

Reply via email to