title: Log4j2 daily log files
body: <p>I want my log files created by log4j2 to have the date pattern in their file name, including the current active file. That is, if todays date is 2016-12-15, I want the current log-file to be lager-2016-12-15.log. When the date changes, I want a new file to be created named lager-2016-12-16.log. </p>
  
  <p>With <code>RollingFileAppender</code> I am not able to get the current active log file to have date pattern in the filename. My Log4j2.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Configuration&gt;
      &lt;Properties&gt;
          &lt;Property name="layoutPattern"&gt;%d{ISO8601} [%t] %-5p [%X{REQUEST_ID}] [%X{CLIENT_ID}] [%X{USER_ID}] %c- %m%n&lt;/Property&gt;
          &lt;Property name="logDir"&gt;${sys:catalina.home}/logs/&lt;/Property&gt;
          &lt;Property name="fileName"&gt;${logDir}lager-${date:yyyy-MM-dd-HHmm}.log&lt;/Property&gt;
          &lt;Property name="filePattern"&gt;${logDir}lager-%d{yyyy-MM-dd-HHmm}.log&lt;/Property&gt;
      &lt;/Properties&gt;
      &lt;Appenders&gt;
          &lt;RollingFile name="LAGER" append="true"
                   fileName="${fileName}"
                   filePattern="${filePattern}"&gt;
              &lt;PatternLayout pattern="${layoutPattern}" charset="UTF-8"/&gt;
              &lt;Policies&gt;
                  &lt;TimeBasedTriggeringPolicy interval="1" modulate="true"/&gt;
              &lt;/Policies&gt;
          &lt;/RollingFile&gt;
      &lt;/Appenders&gt;
      &lt;loggers&gt;
          &lt;Logger name="org.apache.catalina.core.ContainerBase.[Catalina].[localhost]" level="WARN" additivity="false"&gt;
              &lt;AppenderRef ref="LAGER" /&gt;
              &lt;AppenderRef ref="CONSOLE"/&gt;
          &lt;/Logger&gt;
          &lt;Root level="INFO"&gt;
              &lt;AppenderRef ref="LAGER"/&gt;
              &lt;AppenderRef ref="CONSOLE"/&gt;
          &lt;/Root&gt;
      &lt;/loggers&gt;
  &lt;/Configuration&gt;
  </code></pre>
  
  <p>With this config the copying when it rolls over is messed up. Removing the date pattern from the fileName property fixes this, but the the current file does not have the date in its name. </p>
  
  <p>I am running this on a tomee 7.0.1.</p>