Bug 44934 - add helper method to DailyRollingFileAppender to generate schedule file name
Summary: add helper method to DailyRollingFileAppender to generate schedule file name
Status: NEEDINFO
Alias: None
Product: Log4j - Now in Jira
Classification: Unclassified
Component: Appender (show other bugs)
Version: 1.2
Hardware: PC Windows XP
: P2 enhancement
Target Milestone: ---
Assignee: log4j-dev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-05-05 07:44 UTC by Howard
Modified: 2008-08-12 10:04 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Howard 2008-05-05 07:44:39 UTC
Request to add helper method to DailyRollingFileAppender to generate schedule file name.  That way, subclasses can determine the names of the files that the appender will archive to.  i.e.,

Change Log4j v1.2.15 from

	void rollOver() throws IOException {
		...
		String datedFilename = fileName+sdf.format(now);
		...
	}

to

	void rollOver() throws IOException {
		...
		String datedFilename = getScheduledFileName(now);
		...
	}

	/**
	 * Subclasses may override this to change the name
	 * of file that logs get rotated to.
	 *
	 * @param date	[in] (non-null) time used to tag logs being rotated out
	 *
	 * @return name of file [to rotate to]
	 */
	protected String getScheduledFileName(Date date) {
		return fileName + sdf.format(now);
	}
Comment 1 Thorbjørn Ravn Andersen 2008-08-02 15:52:14 UTC
Would it be sufficient with a pattern (with an information set available on the file to be rolled out) or do you want to be able to sub class?  I think there should be a number of overrideable methods to subclass to make things easier.

We had a need for rolling logs, and being able to compress and rename those which would otherwise have been deleted.  It was not easy to do nicely.