
Hi Patrick, Sifting appender could probably help. Here is a sample config file: <configuration> <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" /> <appender name="SIFT" class="ch.qos.logback.classic.sift.SiftingAppender"> <discriminator> <key>testname</key> <defaultValue>unknown</defaultValue> </discriminator> <sift> <appender name="FILE-${testname}" class="ch.qos.logback.core.FileAppender"> <file>${testname}.log</file> <append>false</append> <encoder> <pattern>%d %level %mdc %logger{35} - %msg%n</pattern> </encoder> </appender> </sift> </appender> <root level="DEBUG"> <appender-ref ref="SIFT" /> </root> </configuration> At the beginning each test, you need to set the test's anme in the MDC. For eaxmple, 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 On 18.11.2010 17:01, pwillems66@zonnet.nl wrote:
Hi,
The prudent propertie doesn't work. Any other idea? It looks like the log file is in use. Is their a way to 'unlock' that use by code?
This is what I must realize: For every test I need to create a log file. When the same test start again the previous file must be deleted (or renamed and delete thereafter) and a new one created. Also (test is not running) it must be possible to delete the log file.
-Patrick