On Nov 13, 2007, at 8:43 AM, Mak, Howard wrote:

Hello,

I would like to suggest the following changes to DailyRollingFileAppender. If this is not the appropriate forum for this email, please direct me to the proper channels as I'm new to Log4j. ;)

Feature:

- Allow date pattern to be embedded anywhere in the file name [not just appended to the end].

- Allow easy addition of custom placeholders in file name.

Rationale:

- Preserve file extensions in Windows [so that I can use the same associated program to open both the pending log and the archived logs]

- Use same log4j.properties to output to different files depending on run-time state

- Solves http://www.mail-archive.com/log4j- [EMAIL PROTECTED]/msg06750.html using simpler syntax

Use cases:

1.      Typical usage.

        Given properties:
log4j.appender.F = org.apache.log4j.DailyRollingFileAppender
                log4j.appender.F.File   = trace%d.log
                log4j.appender.F.DatePattern = '.'yyyyMMdd

        Output goes to
                trace.log
                trace.20071111.log
                trace.20071112.log

2. For reverse compatibility, "%d" is implicitly appended if omitted.

        Given:
log4j.appender.F = org.apache.log4j.DailyRollingFileAppender
                log4j.appender.F.File   = trace.log
                log4j.appender.F.DatePattern = '.'yyyyMMdd

        Output goes to
                trace.log
                trace.log.20071111
                trace.log.20071112

3. Custom placeholder illustration. Output to different locations depending on the process ID.

        Given:
log4j.appender.F = custom.DailyRollingFileAppenderSubclass
                log4j.appender.F.File   = trace%p%d.log
                log4j.appender.F.DatePattern = '.'yyyyMMdd
        where
                %p = process ID

        Output goes to
                trace.log
                trace.2342.20071111.log
                trace.2342.20071112.log

Thanks for your consideration.

- Howard
<DailyRollingFileAppender.java.patch>
<DailyRollingFileAppender.java>
<DailyRollingFileAppender.java.orig-1.2.15.bak>
---------------------------------------------------------------------

I think it is likely that all of l the use cases are already covered by the org.apache.log4j.rolling.RollingFileAppender in the extras companion. The org.apache.log4j.rolling.RollingFileAppender was designed to replace the org.apache.log4j.RollingFileAppender and org.apache.log4j.DailyRollingFileAppender.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to