title: Log4J2 (2.6) - Delete logs automatically
body: <p>I'm currently trying to get the Delete Action running in the new Log4j2 (2.6).
  There is the possibility to delete log files, with preconfigured conditions, like file size or age.
  The information about that is really rare on the web, but enough to configure it someway.
  Anyway, it's not working for me.</p>
  <p>We are using a properties file to configure our Log4J2.
  The writing works absolutely as expected, only the deletion doesn't.</p>
  <p>So, here's a snippet of our properties file:</p>
  <h1>main log file</h1>
  <pre><code>appender.rolling.type = RollingFile
  
  appender.rolling.name = RollingFile
  
  appender.rolling.fileName = ${filename}
  
  appender.rolling.filePattern = log/%d{yyyyMMdd}_xxxlog.zip
  
  appender.rolling.layout.type = PatternLayout
  
  appender.rolling.layout.pattern = %d{yyyy-MM-dd HH:mm:ss.SSS} %-5p %c{1}:%L - %m%n
  
  appender.rolling.policies.type = Policies
  
  appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
  
  appender.rolling.policies.time.interval = 2m
  
  appender.rolling.policies.time.modulate = true
  
  appender.rolling.strategy.type = DefaultRolloverStrategy
  
  appender.rolling.strategy.action.type = Delete
  
  appender.rolling.strategy.action.basepath = /log
  
  appender.rolling.strategy.action.maxdepth = 1
  
  appender.rolling.strategy.action.condition.type = IfLastModified
  
  appender.rolling.strategy.action.condition.age = 1D
  
  appender.rolling.strategy.action.PathConditions.type = IfFileName
  
  appender.rolling.strategy.action.PathConditions.glob = *.log
  
  All starts with the line: **appender.rolling.strategy.action.type = Delete**
  </code></pre>
  <p>Next there comes the basepath. Here I tried multiple options, like an absolute path or relative path.
  I also tried it with and without starting and ending slashes... some of that tries leads to an error in the console, so at least &quot;/log&quot; seems to be the correct way (also you can use /log/).</p>
  <p>On the third line, &quot;appender.rolling.strategy.action.maxdepth = 1&quot; I tried experiemented with some more values. Just to be sure, that this is not the problem. All logfiles are in the root directory, so 1 seems to be correct.</p>
  <p>Next line: <strong>appender.rolling.strategy.action.condition.type = IfLastModified</strong></p>
  <p>I just looked in the code, after it wasn't working as expected, just to be absolute sure, there is a function IfLastModified. It is all there, and in the console I can confirm, its called and &quot;working&quot;.</p>
  <p>Next: <strong>appender.rolling.strategy.action.condition.age = 1D</strong>
  Here I tried multiple options as well. 1 m , 1 D... and to be sure, I copied old logfiles in the directory, which are older than 1 minute and / or older than 1 day.</p>
  <p><strong>appender.rolling.strategy.action.PathConditions.type = IfFileName</strong></p>
  <p>Here's the condition, which files you want to delete. I started with *.log
  but I also tried an absolute name logfile.log and many other possibilities. I have .zip, .log, .txt...</p>
  <p>Then I come over the possiblity, that the software may not have the rights to delete something in that folder. I gave the files permission and access to all things, just like write, read, delete.
  After all, I'm able to say, that the properties configuration seems to be fine, because there no errors.
  But it's just not working.</p>
  <p>Ah, last but not least, I also figured out that blank spaces at the end of a line cause errors.
  There are no blank spaces... that's not the problem at all.</p>
  <p>Has anybody an idea why it is not working?
  I appreciate any help or idea.
  Thank you very much.</p>
  <p>Have a nice day,</p>
  <p>Timm</p>