DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=29835>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=29835 DailyRollingFileAppender: cannot delete log file when specify invalid date pattern Summary: DailyRollingFileAppender: cannot delete log file when specify invalid date pattern Product: Log4j Version: 1.2 Platform: All OS/Version: Windows XP Status: NEW Severity: Normal Priority: Other Component: Appender AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] I'm using log4j 1.2.8 on Windows XP. I'd like to achieve automatic-old-log-deletion when the log rolls over. I have made a subclass of DailyRollingFileAppender and have had two problems. Problem1)rollOver() is package private method in DailyRollingFileAppender, so that I have to override subAppend(), which is not smart way to sense a rollover timing. Problem2)one of my subclass's constructor is look like this: public AutomaticallyRemovingDailyRollingFileAppender (Layout layout, String filename, String datePattern) throws IOException { super(layout, filename, datePattern); } When a client code calls this constructor like this: AutomaticallyRemovingDailyRollingFileAppender appender = new AutomaticallyRemovingDailyRollingFileAppender( new PatternLayout(), // appropriate "log.txt", // also appropriate "hogehoge" // not appropriate as date pattern string ); DailyRollingFileAppender's constructor calls its super class's constructor, which results to open the specified file, and then DailyRollingFileAppender#activateOptions() try to invoke SimpleDateFormat#format() with specified date pattern ( i.e. "hoge" in this example). The format() method throws IllegalArgumentException, so that DailyRollingFileAppender's constructor throws IllegalArgumentException. This means that A) The client code can not get a AutomaticallyRemovingDailyRollingFileAppender's instance. B) The log file is opend, even though there is no way to close it. These are very annoying problems. My suggestion is: AnswerForProblem1) Change accessibility of rollOver() to protected. AnswerForProblem2) Insert an error handling code for closing the log file in DailyRollingFileAppender's constructor, or check whether the specified date pattern is valid or not. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
