logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ceki Gulcu <...@urbanet.ch>
Subject RE: JSPAppender?
Date Wed, 10 Jan 2001 13:56:33 GMT

Kirk,

I think your proposal is misguided. First and foremost, 
Category.getInstance will not create new instances when called with the 
same name argument. For example,

Category x = Category.getInstance("hello");
Category y = Category.getInstance("hello");

The variables x and y refer to the same object. I guess the rest of the 
proposal falls apart. Would you concur?

If your goal is to have a separate output target for each client request, 
then IMHO log4j can deal with this pretty well. I suggest that you look at 
the code of org/apache/log4j/net/SocketServer. (This is  new code 
introduced in 1.0.) The main idea there is to define a separate hierarchy 
per host.

Log4j defines all the plumbing for dealing with different 
hierarchies.  However, it is your responsibility to tell log4j when to use 
which hierarchy as log4j is not aware of your context. I hope this helps, Ceki

At 08:18 10.01.2001 -0500, you wrote:
>I'm new to log4j as well, but I've spent the past couple of days trying to
>getup to speed.  The problem you address is having a separate output target
>for each client request, and it appears to me that log4j's design is not set
>up for this.
>
>To log output, you must have a Category object which you obtain with the
>getInstance method.  The instance must supply a category name string in
>order to get the object.  Since you want a separate instance for each web
>request, the name string needs to be unique to the request.  You could
>generate a name using a session id or Cookie.  Since Category instances are
>not capable of being destroyed, you would theoretically continue to create
>these instances for each web request until the JSP JVM runs out of memory.
>
>To route output to the JSP, you would need an Appender which writes its
>output to the Writer returned from HttpServletResponse.getWriter().
>
>Given the above, I think you could implement a workable solution as follows:
>
>a) Extend Category to implement a pool of instances.  Override the
>getInstance method to return an object from the pool.  If the pool is empty
>use the CategoryFactory to get a new one.  Add a method such as free() which
>your JSP would call to return the object to the pool.  This prevents using
>up memory.  You can look at the MyCategory class to see how to do most of
>this.
>
>b) Extend AppenderSkeleton to implement a JSP Appender.  The constructor
>would have the JSP output Writer as its parameter.  Add this Appender to the
>custom Category object.
>
>c) Pass the Category instance within your JSP classes as opposed to coding
>the getInstance in each one.
>
>d) At the end of the JSP return the Category to the pool.  You can leave the
>Appender "attached" to the Category for re-use.
>
>Since you will not be able to configure your Category or Appender via
>Properties or XML, you will have to code all of the configuration as well
>(e.g., Layout, Pattern, etc.)
>
>List members ... does this sound about right?
>
>-----Original Message-----
>From: Ceki Gulcu [mailto:cgu@urbanet.ch]
>Sent: Tuesday, January 09, 2001 6:16 PM
>To: LOG4J Users Mailing List
>Cc: tom.palmer@interpath.net
>Subject: Re: JSPAppender?
>
>
>
>Tom,
>I am no JSP/Servlet expert. I don't know if a general solution is feasible
>but I think a site specific solution can be easily written by emulating the
>SMTPAppender. Regards, Ceki
>
>At 17:02 09.01.2001 -0500, you wrote:
> >Just downloaded log4j and started using it for JSP/Servlet development -
> >very nice.  Question: has anyone implemented an output option that will
> >log back to the JSP-generated page?  I'd like to be able to setup the
> >log object in the page and then pass it to various utility classes.
> >When these classes write to the log, it ends up on the output page for
> >quick viewing.
> >
> >Thanks -
> >
> >--
> >Tom Palmer                                  Interpath Communications
> >Interactive Technologies Consulting         1700 Perimeter Park West
> >tom.palmer@interpath.net                    Morrisville, NC 27560
> >919-253-5937
> >919-253-6586 (fax)
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: log4j-user-help@jakarta.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-user-help@jakarta.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-user-help@jakarta.apache.org


Mime
View raw message