0

I want a sample code for log4j.properties which will add date in the file name when creating. Say example i have a file catilina.2013-02-13.log which is in the format as catilina.{yyyy-mm-dd}.log

I used the below code but it does not work for me

log4j.appender.FILE.File=${log}/catilina_%d{yyyy-MM-dd}.log 

Thanks,

Sravan Kumar
  • 673
  • 1
  • 7
  • 12

1 Answers1

0

I could recommend use Logback instead, it's faster and with a great programmer behind, in the docs you can easily find what you're looking for (separation by dates, even with size limits, it's nice!), something with an appender

    <timestamp key="bySecond" datePattern="yyyyMMdd'T'HHmmss"/>
    <appender name="FILE" class="ch.qos.logback.core.FileAppender">
        <!-- use the previously created timestamp to create a uniquely named log file -->
        <file>log-${bySecond}.txt</file>
        <encoder>
            <pattern>%logger{35} - %msg%n</pattern>
        </encoder>
    </appender>

More in appenders

rekiem87
  • 1,565
  • 18
  • 33