[logback-user] Delete log file

pwillems66 at zonnet.nl pwillems66 at zonnet.nl
Tue Nov 16 17:47:13 CET 2010


Hi,

For every test we do, we need a log file.
If the test fails, the log file can be viewed and the errors can be fixed.
If the errors are fixed and the test runs again and there are no 
errors, I want to delete this log file.
Is it possible to delete a log file? (While file is is use by logback!)
If yes, how?

My configuration is:
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>

  <appender name="RootSiftAppender" 
class="ch.qos.logback.classic.sift.SiftingAppender">
    <append>false</append>    <discriminator>
      <Key>testname</Key>
      <DefaultValue>testrun</DefaultValue>
    </discriminator>
    <sift>
      <appender name="FILE-${testname}" 
class="ch.qos.logback.core.rolling.RollingFileAppender">
        <File>${testname}.log</File>
        <rollingPolicy 
class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
          <FileNamePattern>${testname}.%i.log</FileNamePattern>
          <MinIndex>1</MinIndex>
          <MaxIndex>1</MaxIndex>
        </rollingPolicy>
        <triggeringPolicy 
class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
          <MaxFileSize>5MB</MaxFileSize>
        </triggeringPolicy>
        <layout class="ch.qos.logback.classic.PatternLayout">
          <Pattern>%d{ISO8601} - %msg%n</Pattern>
        </layout>
      </appender>
    </sift>
  </appender>
   <root level="error">
    <appender-ref ref="RootSiftAppender" />
  </root>
</configuration>



More information about the Logback-user mailing list