The DailyRollingFileAppender is not designed to have the date in the "current" log's name. It is designed such that the current log is named something like MyLog.log, and then as it rolls, the archived logs are named Mylog_2010-11-15.log.
From the
javadoc of DailyRollingFileAppender:
For example, if the File option is set to /foo/bar.log and the DatePattern set to '.'yyyy-MM-dd, on 2001-02-16 at midnight, the logging file /foo/bar.log will be copied to /foo/bar.log.2001-02-16 and logging for 2001-02-17 will continue in /foo/bar.log until it rolls over the next day.
As a side note, the
RollingFileAppender in
LogBack (a newer Logging Framework, written by the same people that first developed log4j, intended to be a successor to log4j) is more sophisticated and can be configured such that the "current" log name has the date in it. It can also be set to only keep x number of rolled logs (for example 60 days), deleting any older logs. This is a shortcoming of the DailyRollingFileAppender in Log4j as it cannot be configured to clean up old logs. You can use the
Simple Logging Facade for Java (SLF4J) API to make it so LogBack handles all the Log4J logging for a project/application that uses log4j. It's as simple as replacing the log4j.jar file in your classpath with the log4j-over-sl4fj.jar from the SLF4J API and putting the logback jar in the classpath. Then replace your log4j configuration file with a logback configuration file. See the SLF4J
Bridging legacy APIs page for details. Logback brings a number of advantages to the table over log4j. See the
Reasons to prefer logback over log4j page for more information. (I use to be a log4j fanatic until I discovered SLF4J and Logback. Now that is the logging framework I evangelize, as you can probably tell.)