You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Mak, Howard" <hm...@vaultus.com> on 2007/11/13 15:43:42 UTC
DailyRollingFileAppender: put date anywhere in file name + support
custom placeholders
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-user@logging.apache.org/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
Re: DailyRollingFileAppender: put date anywhere in file name + support
custom placeholders
Posted by Will Sargent <wi...@gmail.com>.
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. ;)
Being as I just went through this myself:
The best way to contribute code is to create a bug with a description of
the patch, and then add the patch as an attachment. If you can say that
you're donating the code to the ASF, that helps legally.
Bugzilla site is here:
http://issues.apache.org/bugzilla/
Contributer's Tech Guide is here:
http://apache.org/dev/contributors.html
Will.
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org
Re: DailyRollingFileAppender: put date anywhere in file name + support custom placeholders
Posted by Curt Arnold <ca...@apache.org>.
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-
> user@logging.apache.org/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: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org