Reputation: 981
Can one configure log4j RollingFileAdapter not to change logfile name after midnight? With the configuration (see below) I'm using, if the logging starts on 2017-09-15 and continues overnight everything after 00:00 will be logged to another logfile 2017-09-16. I'd like to get full log in to the same file. Only if another run starts on 2017-09-16 then a new log would be created.
<appender name="file-output" class="org.apache.log4j.rolling.RollingFileAppender">
<param name="ImmediateFlush" value="false"/>
<param name="Threshold" value="INFO"/>
<rollingPolicy name="file" class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
<param name="FileNamePattern" value="log/${logfilename}_%d{yyyy-MM-dd}.log"/>
</rollingPolicy>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5p %m%n"/>
</layout>
</appender>
Upvotes: 1
Views: 610
Reputation: 352
sounds like you donot need ROTATE file appender.
in your situation, i will advise you just use normarl file appender, this will make all log records into one file. all you need to do is name it by date pattern, like "yyyy-MM-dd.log".
ps: if you want rotate, logrorate
tool on linux is a good choice too.
Upvotes: 1