aspose file tools*
The moose likes Other Java Products and Servers and the fly likes log4j DailyRollingFileAppender Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Products » Other Java Products and Servers
Bookmark "log4j DailyRollingFileAppender" Watch "log4j DailyRollingFileAppender" New topic

log4j DailyRollingFileAppender

Benjamin Hundley
Ranch Hand

Joined: Mar 06, 2006
Posts: 53
I have configured a DailyRollingFileAppender in log4j but I don't seem to see different logs for different dates. Here is my configuration.

<appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="log/my_log.log" />
<param name="Append" value="false" />
<param name="Threshold" value="INFO" />
<param name="DatePattern" value="'.'yyyy-MM-dd" />
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
<param name="ConversionPattern" value="%d %-5p [%c] %m%n" />

The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
<param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x)

My program runs once a day... it isn't continously running. So is this why it doesn't seem to create a new log file? Also all I see is the my_log.log file. But I don't see any date in the title? Is this running correctly? Am I missing something?
Benjamin Hundley
Ranch Hand

Joined: Mar 06, 2006
Posts: 53
Also another problem, it overwrites the old log every time I run it with the new log. I had expected it to append to the log.
Benjamin Hundley
Ranch Hand

Joined: Mar 06, 2006
Posts: 53
Doh! I think I just figured it out. Appender property was set to false.
It is sorta covered in the JavaRanch Style Guide.
subject: log4j DailyRollingFileAppender
Similar Threads
Capture logs to file via log4j.xml
Jboss final start up message not comes up in console
Help? - Reloading log4j.xml config without jboss restart
invalid console appender .....
How to configure a separate log file(Log4j) for a specific application in JBoss?