title: log4j fileappender doesn't switch to the new file when logrotate rotates the log file
body: <p><strong>Context:</strong></p>
  
  <p>I want to use log4j to write audit-related logs to a specific log file, let's say audit.log. I don't want to use syslogappender(udp based) because I don't want to be tolerant to data loss. Plus, I am using logrotate to rotate the audit.log when the file gets to certain size. </p>
  
  <p><strong>Problem:</strong></p>
  
  <p>I am encountering is that, when logrotate rotates the file audit.log to audit.log.1, log4j keeps writing to audit.log.1 other than writing to the audit.log. </p>
  
  <p><strong>Possible approaches:</strong></p>
  
  <ol>
  <li><p>I know I can use rollingfileappender to do the log rotation other than use logrotate, so when rollingfileappender rolls the file, it switch to the new file without hassles. But the reason I can't use rollingfileappender is that I want to use logrotate's post rotate feature to trigger some scripts after the rotation happens which can't be provided by rollingfileappender.</p></li>
  <li><p>Another desperate way I can think of is to write a log4j customized appender myself to close the log file(audit.log.1) and open the new one(audit.log) when it detects the file is rotated. </p></li>
  <li><p>I never used ExternallyRolledFileAppender, but if it's possible to use logrotate post rotate to send the signal to ExternallyRolledFileAppender and make log4j aware the file is rotated, and start writing to the new file?</p></li>
  </ol>
  
  <p><strong>Question:</strong></p>
  
  <p>Just wondering is there some appender like that already been invented/written? or do I have other options to solve this?</p>