Details
-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
None
-
None
-
None
Description
I'm using rolling file appender with pattern layout and file header option. File header contains some static info about the application, its components, system environment, etc.
When the current log file is being deleted, logback creates the new one (it's great, log4j just silently stops logging any more), but there are no file header.
In my practice cleaning all logs on fly is a common case for development process.
Simple config to reproduce:
<configuration> <appender name="application" class="ch.qos.logback.core.FileAppender"> <file>application.log</file> <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder"> <layout class="ch.qos.logback.classic.PatternLayout"> <pattern>%d{HH:mm:ss.SSS} - %msg%n</pattern> <fileHeader>SomefileHeader</fileHeader> </layout> </encoder> </appender> <root level="info"> <appender-ref ref="application" /> </root> </configuration>
Simple application to run:
public class Main { private final static Logger log = LoggerFactory.getLogger(Main.class); public static void main(String[] args) throws InterruptedException { while (true) { log.info("the quick brown fox jumps over the lazy dog"); Thread.sleep(1000); } } }
To delete the current log file on windows I'm using the LockHunter utility (to kill the file handler without stopping the application).