20 messages in org.apache.logging.log4j-userRE: Separate log file per servlet
FromSent OnAttachments
Horry, Adam JJun 11, 2004 10:05 am 
James StaufferJun 11, 2004 10:20 am 
Shapira, YoavJun 11, 2004 10:23 am 
Horry, Adam JJun 11, 2004 10:29 am 
Horry, Adam JJun 11, 2004 10:33 am 
Lutz MichaelJun 11, 2004 10:33 am 
Shapira, YoavJun 11, 2004 10:58 am 
James StaufferJun 11, 2004 11:02 am 
Horry, Adam JJun 11, 2004 11:48 am 
James StaufferJun 11, 2004 11:50 am 
Ceki GülcüJun 11, 2004 12:08 pm 
Scott DeboyJun 11, 2004 12:13 pm 
Horry, Adam JJun 11, 2004 1:29 pm 
Horry, Adam JJun 11, 2004 1:37 pm 
Horry, Adam JJun 11, 2004 1:40 pm 
James StaufferJun 11, 2004 1:42 pm 
Ceki GülcüJun 11, 2004 1:49 pm 
Scott DeboyJun 11, 2004 1:50 pm 
Horry, Adam JJun 11, 2004 2:10 pm 
Ceki GülcüJun 11, 2004 2:16 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:RE: Separate log file per servletActions...
From:Ceki Gülcü (ce@qos.ch)
Date:Jun 11, 2004 2:16:30 pm
List:org.apache.logging.log4j-user

As long as you don't mark the logger variable in class X as static, the solution I suggested earlier should work like a charm.

At 11:10 PM 6/11/2004, you wrote:

Sorry, in an earlier java prototype we had problems with static objects. There were two applications that use separate loggers. Everything worked well because they were in their own JVM. When they were combined into one JVM, the first one to be invoked got the static object and both then wrote to that one. Which is one of the reason we moved to log4j to do logging. So it was on my mind when I was thinking how the multiple servlets using the threadLocal idea would work. I should not have asked since now that I thought about it some more, it should not be a problem.

Just finished trying out the chainsaw idea. On to learning more about localThreads (as you suspected).

-----Original Message----- From: Ceki Gülcü [mailto:ce@qos.ch] Sent: Friday, June 11, 2004 4:49 PM To: Log4J Users List Subject: RE: Separate log file per servlet

At 10:38 PM 6/11/2004, you wrote:

What about static objects in the JVM? Would each Servlet get their own instance of X or will it get the static one?

What do you mean by static objects in the JVM

If the Servlet spawned off threads? Then it should still work because you have not changed the TL.

Does that sound right? I was just trying to mentally think what will happen when servlet 2 comes up.

servlet1 sets the TL to "servlet1" servlet 1 creates an instance of X, say x1 while constructing x1, x1 reads TL, the read value is "servlet1" the constructor retrieves a logger whose name depends on the value of TL servlet 1 calls a method on x1, say foo() x1.foo() logs with that logger specific to the x1

servlet2 sets its TL to "servlet2" servlet2 creates an instance of X, say x2 while constructing x2, x2 reads TL, the read value is "servlet2" the constructor retrieves a logger whose name depends on the value of TL servlet2 calls a method on x2, say foo() x2.foo() logs with the logger specific to the x2

x1.foo() eventually returns servlet1 eventually returns, before returning it sets TL to null

x2.foo() eventually returns servlet2 eventually returns, before returning it sets TL to null

Are you familiar with thread local variables? If not, invest a few minutes to experiment.

http://java.sun.com/j2se/1.3/docs/api/java/lang/ThreadLocal.html

-- Ceki Gülcü

For log4j documentation consider "The complete log4j manual" ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp

-- Ceki Gülcü

For log4j documentation consider "The complete log4j manual" ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp