On Jan 24, 2008, at 1:13 PM, Alex Qi (yuqi) wrote:
I defined a RollingFileAppender in my log4j config file, it works fine for simple logging request. But when many loggers writing to the same log file, it behaves like this: original log file is: "foo.log", it should roll to "foo.log.1", "foo.log.2" now, "foo.log" did roll to "foo.log.1", but the new message also write to "foo.log.1" instead of the newly generated "foo.log" Is this a known bug? Thanks. Regards, -- Alex Qi
That is a very common behavior when you have more than one appender attempting to use the same file name pattern. It should not occur if you only have one appender. If the same configuration file is loaded by multiple independent instances of log4j (for example, in different JVM's or class loaders), there will be multiple independent implementations of the appender and there is no attempt (or any good mechanism to attempt) to coordinate their behavior.
Writing to "foo.log.1" would occur when one instances of the appender has rolled over and renamed the old "foo.log" to "foo.log.1". That appender would have closed its output stream on the old file and opened a new one on the new file. A different appender would not be aware of that rollover and would continue to write to the same output stream that it always, but the name of the file resource that that stream is associated with has changed underneath it. On a Windows box, the rename on the rollover would have likely failed, but Unix like OS's allow open files to be renamed.
If you configuration file has multiple instances of RFA with the same pattern, you either need to reduce those to one instance or change the patterns on the instances. If you are running under an application server (Tomcat, JBOSS, etc), the location of the log4j.jar can determine if a common instance is used for all applications or if multiple instances are used.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
