[logback-user] Delete log file

pwillems66 at zonnet.nl pwillems66 at zonnet.nl
Thu Nov 18 17:35:05 CET 2010


> Hi Patrick,

> Sifting appender could probably help. Here is a sample config file:

public class MyTest {

    Logger logger = LoggerFactory.getLogger(Foo.class);

    @Before
    public void setUp() {
       MDC.put("testname", "myTest");
    }

    @Test a() {
       logger.info("a says hello");
       ...
    }

    @Test b() {
       logger.info("b says hello");
       ...
    }
}

public class MyOtherTest {

    Logger logger = LoggerFactory.getLogger(Foo.class);

    @Before
    public void setUp() {
       MDC.put("testname", "MyOtherTest");
    }

    @Test x() {
       logger.info("a says hello");
       ...
    }
}


>> Let us know if it works...
>> -- Ceki

Hi Ceki,

It works except for the delete. When I call the test (class) MyTest 
(multiple times) logback don't delete the log file but append it.

The first time when the Logger initialize the file is truncated but not 
for the second and more times until the Logger must initialize again.

-Patrick




More information about the Logback-user mailing list