F
FET
Hi everyone,
Consider the following piece of code:
Logger mylogger = Logger.getLogger(Log4JFileDeletionTest.class);
public Log4JFileDeletionTest() throws Exception
{
FileAppender fapp = new FileAppender(new
XMLLayout(),"/tmp/Log4JFileDeletionTest.log",true);
mylogger.setLevel(Level.DEBUG);
mylogger.addAppender(fapp);
mylogger.info("This is a test log");
Thread.sleep(7000);
mylogger.info("This is after deleting the file");
}
If during the Sleep(), I delete the log file, then none of the
subsequent log statements re-create the file. It remains deleted, no
exceptions get thrown and all the logs are lost.
Is there any solution to this, other than modifying the log4J code ?
Thanks in advance.
Consider the following piece of code:
Logger mylogger = Logger.getLogger(Log4JFileDeletionTest.class);
public Log4JFileDeletionTest() throws Exception
{
FileAppender fapp = new FileAppender(new
XMLLayout(),"/tmp/Log4JFileDeletionTest.log",true);
mylogger.setLevel(Level.DEBUG);
mylogger.addAppender(fapp);
mylogger.info("This is a test log");
Thread.sleep(7000);
mylogger.info("This is after deleting the file");
}
If during the Sleep(), I delete the log file, then none of the
subsequent log statements re-create the file. It remains deleted, no
exceptions get thrown and all the logs are lost.
Is there any solution to this, other than modifying the log4J code ?
Thanks in advance.