title: Apache web server - purge log files
body: <p>We have Apache server running in a server and using rotate logs, we roll logs . </p>
  
  <p>I can set up autopsy’s job to remove them . But does Apache have any log4j setup to roll up logs and keep only n number of rolled up logs.
  Is there any way to purge them automatically which is 30 day old.</p>
  
  <p>So i use following format and works fine to roll them and it works fine here</p>
  
  <pre><code>  CustomLog "|/local/web/apache24/bin/rotatelogs /local/web/apache24/logs/${instancename}.accesstest_log_v.%Y-%m%d%H%M 86400" common
  </code></pre>
  
  <p>what would be the option to limit to number of files, I tried below  and its not working</p>
  
  <pre><code>CustomLog "|/local/web/apache24/bin/rotatelogs -n 5 /local/web/apache24/logs/${instancename}.accesstest_log_v.%Y-%m%d%H%M 86400" common
  </code></pre>