On Sep 2, 2008, at 3:38 PM, David Britton wrote:

Hello --

I'm not sure if this is the correct way to do this, but my colleague and I have developed a new appender called a PatternFileAppender. I did not see anything else like this in the log4j distribution, but it helped us
solve our particular problem, and I think it's a good general purpose
appender. If someone knows of another appender like this, I would love
to hear about it.

I went to make an official patch for log4j 1.2, but I found that the
code needed to be compatible with 1.2 source compatibility level. Since the code uses generics in it's use of the LinkedHashMap data structure,
it needs 1.5 or later to compile correctly.

Anyway, I've attached the file, if there is an "official" way to do
this, please point me in the right direction.

Here is the high-level details of the appender:

* Can process a filename as a pattern, with all substitutions available.
 (e.g., MDC, date, variable, level, class, ...)

* Interesting use cases we are using it for:
- Separate log file per "thread" using MDC (note that "thread" could
     be any separation desired, log level, date, time, etc).

* Keeps a cache of the latest 20 open file streams, so as not to
 overload the OS/filesytem/etc

* Adds performance penalty in that each log message will generate an
 extra pattern lookup.  Note that this already happens for the message
 itself, so this does not seem like a huge impact.


Let me know any feedback...  Thanks!

--
David Britton <[EMAIL PROTECTED]>
< PatternFileAppender .java >---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Could you compare it with the MultiFileAppender that has been languishing in the sandbox for a while? Search the archives for MultiFileAppender. Source code at http://svn.apache.org/repos/asf/logging/sandbox/log4j/multifile .

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

Reply via email to