title: Adding timestamp to a log file using Logback-test.xml
body: <p>Currently my Spring-boot application logs to a file named: <code>myLog.log</code>, this is working as intended, however I would like the log file to have a <code>timestamp</code> at the end of it and create a <strong>new file</strong> each time it is ran.</p>
  
  <p>I have tried to implement this in my <code>logback-test.xml</code> file shown below, but it is just giving me the filename: myLog.log <strong>without</strong> a timestamp.</p>
  
  <p>How can I fix this?</p>
  
  <p><strong>Logback-test.xml:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;configuration&gt;
      &lt;include resource="org/springframework/boot/logging/logback/base.xml"/&gt;
  
      &lt;logger name="org.springframework.web" level="INFO"/&gt;
  
      &lt;!-- Send debug messages to System.out --&gt;
      &lt;appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"&gt;
          &lt;!-- By default, encoders are assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder --&gt;
          &lt;encoder&gt;
              &lt;pattern&gt;%d{HH:mm:ss.SSS}  - %msg%n&lt;/pattern&gt;
          &lt;/encoder&gt;
      &lt;/appender&gt;
  
      &lt;appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"&gt;
          &lt;file&gt;path/to/my/file/mylog.log&lt;/file&gt;
          &lt;encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"&gt;
              &lt;Pattern&gt;%d{yyyy-MM-dd_HH:mm:ss.SSS} - %msg%n&lt;/Pattern&gt;
          &lt;/encoder&gt;
  
          &lt;rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"&gt;
              &lt;FileNamePattern&gt;mylog.%i{yyyy-MM-dd_HH:mm:ss.SSS}}.log&lt;/FileNamePattern&gt;
              &lt;MinIndex&gt;1&lt;/MinIndex&gt;
              &lt;MaxIndex&gt;10&lt;/MaxIndex&gt;
          &lt;/rollingPolicy&gt;
  
          &lt;triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"&gt;
              &lt;MaxFileSize&gt;2MB&lt;/MaxFileSize&gt;
          &lt;/triggeringPolicy&gt;
      &lt;/appender&gt;
  
      &lt;logger name="com.my.package" level="INFO" additivity="false"&gt;
          &lt;appender-ref ref="STDOUT" /&gt;
          &lt;appender-ref ref="FILE" /&gt;
      &lt;/logger&gt;
  
      &lt;!-- By default, the level of the root level is set to DEBUG --&gt;
      &lt;root level="INFO"&gt;
          &lt;appender-ref ref="STDOUT" /&gt;
      &lt;/root&gt;
  
  &lt;/configuration&gt;
  </code></pre>