You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by "Heupel, Sebastian" <Se...@sdm.de> on 2003/04/16 09:17:02 UTC
Log4j and Threadsafeness
Hallo,
thought that log4j is thread safe. Now I noticed the following in my Web application (Weblogic Express 6.1) during concurrent access of a Servlet
* Logfile
...
2003-04-14 16:17:48,705, < data to log >
2003-04-14 16:17:49,705, < data to log >
2003-04-14 16:17:50,705, < data to log >
2003-04-14 16:17:51,705, < data to log >
2003-04-14 16:17:52,705, < data to log >
> ... and suddenly this piece of text:
-04-14 16:17:52,705, < data to log >
...
2003-04-14 16:17:55,705, < data to log >
2003-04-14 16:17:56,705, < data to log >
the same is happening when logging exceptions - only a part of the stack trace is logged. The rest seems to be overwritten ...
* Log4j Configfile
log4j.rootLogger=DEBUG, logfile
log4j.logger.com.bmw.xcaesar.xlogging.XBenchmark=INFO
log4j.appender.logfile=org.apache.log4j.FileAppender
log4j.appender.logfile.File=${logFileName}
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%d, %m%n
* and the code
protected void doGet(HttpServletRequest aRequest, HttpServletResponse aResponse)
throws ServletException, java.io.IOException
{
HttpSession session = aRequest.getSession(true);
synchronized (session)
{
// ... perform the request
...
mLogging.debug(logString);
}
}
Anybody who knows about this ? All I heard was that log4j is thread-safe. Perhaps this happens because the application runs in a clustered environment ?
Thanks,
Sebastian
---
Sebastian Heupel mailto:Sebastian.Heupel@sdm.de <ma...@sdm.de>
sd&m AG http://www.sdm.de <http://www.sdm.de>
software design & management
Thomas-Dehler-Str. 27, 81737 Muenchen, Germany
Tel +49 89 63812-265 Fax -490