On Aug 15, 2008, at 10:59 AM, Peter Steele wrote:
We use the DailyRollingAppender, defined as follows in our config
file:
<appender name="FILE"
class="org.jboss.logging.appender.DailyRollingFileAppender">
<errorHandler
class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="File" value="<logfile>"/>
<param name="Append" value="true"/>
<!-- Rollover at midnight each day -->
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%c{1}] %m%n"/>
</layout>
</appender>
Several applications log to the same log file using this appender.
What’s happening is when the rollover occurs at midnight, some
processes still log to the original file, which has now been
renamed, whereas others log to the main log file as they should. I’m
suspecting that this is an error on our part and we should not have
multiple processes all log to the same file, although I’ve heard
that others do this. What’s the solution?
log4cxx's RFAs mimics log4j's RFAs and having multiple independent
applications attempt to write to the same location is a common
misconfiguration problem in the log4j world. There is no mechanism
(at least using java.io) to detect the situation, so the best we can
do is to tell people not to do it.
You are apparently running on non-Windows platform. What is occurring
is that one application rolls over renaming the previous log file and
creates the new log file, when other applications decide that it is
time to roll over, then fail to create the new log file and continue
to write to their old handle (which has been renamed since they
originally opened it).
There has been a long stalled initiative to develop a
MultiFileAppender for log4j which may handle the situation more
gracefully (not its main objective), but that development has been
stalled for a year or so.