20 messages in org.apache.logging.log4j-userSeparate 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:Separate log file per servletActions...
From:Horry, Adam J (adam@lmco.com)
Date:Jun 11, 2004 10:05:39 am
List:org.apache.logging.log4j-user

The web server is configured to be one JVM for all the servlets. Numerous people are developing different classes. We want each Servlet to write to its own log.

Class X { ... xLog = getLogger( "DEBUG" ); ... xLog.info( "message" ); ... }

Class ServletY extends HttpServlet { ... xLog = getLogger( "DEBUG" ); ... configureAndWatch( ); ... xLog.info( "message" ); ... someMethod() { new X(); } }

Class ServletZ extends HttpServlet { ... xLog = getLogger( "DEBUG" ); ... configureAndWatch( ); ... xLog.info( "message" ); ... someMethod() { new X(); } ... }

log4j.properties: ... Logger name="DEBUG" Appender A ... Appender A ...

Class A extends DailyRollingFileAppender { String _file = null;

a( ) { super.init(); setFile( "" ); }

setFile( aFile ) { // Throw stack trace to figure out which servlet called you ... // add path and .log to get filename like /tmp/ServletY.log or // /tmp/ServletZ.log _file = "newFile"; } }

Now the problem: When the first servlet comes up, say ServletY, it configures and creates /tmp/ServletY.log. ServletY and X write to the file and everyone is happy. Now the next servlet comes up, say ServletZ. It configures and creates /tmp/ServletX.log. Now everything writes to this log but not the other.

So I guess what I am looking for is how I can I do logging on a servlet basis that writes to a particular log. The various support classes need to call something generic because they do not know which specific servlet called them.

Thanks, Adam