Bug 45165 - Multifile Appender
Summary: Multifile Appender
Alias: None
Product: Log4j - Now in Jira
Classification: Unclassified
Component: Appender (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 enhancement
Target Milestone: ---
Assignee: log4j-dev
Depends on:
Reported: 2008-06-09 00:32 UTC by Armin Häberling
Modified: 2009-10-01 04:44 UTC (History)
2 users (show)

MultiFileAppender implementation (4.28 KB, application/zip)
2008-06-09 00:32 UTC, Armin Häberling
MultiFileAppender.java - new version (12.33 KB, text/x-java)
2008-06-10 06:29 UTC, Armin Häberling

Note You need to log in before you can comment on or make changes to this bug.
Description Armin Häberling 2008-06-09 00:32:13 UTC
Created attachment 22098 [details]
MultiFileAppender implementation

The multifile sandbox project (http://svn.apache.org/repos/asf/logging/sandbox/log4j/multifile) is currently in an unusable state.

The goal of this Bug is to get a working implementation of the Multifile Appender.

I attach a basic implementation of the MultiFileAppender.
It uses a SubAppender class which inherits from FileAppender and encapsulates the File handling stuff.
The append method manages the open files and delegates the log events to the SubAppenders.

There is a simple test case, that instantiates some threads, that log simultaneously.

Any comments are welcome
Comment 1 Armin Häberling 2008-06-10 06:29:10 UTC
Created attachment 22104 [details]
MultiFileAppender.java - new version

A new version of the MultiFileAppender class.

The old one had a NullPointerException if a file could not be opened.
I fixed that and also did some refactoring: I removed the dependency on the FileAppender. This makes the code is much clearer and the error handling easier.
Comment 2 Curt Arnold 2008-06-13 12:46:49 UTC
Attachment 22104 [details] committed in rev 667628.
Comment 3 Curt Arnold 2008-06-13 15:20:25 UTC
Will probably make some of the extension points "private" until internals settle down.  Was intending to use java.nio and would likely move formatting and encoding up to the Appender itself.  Might make MFA a specialization of a MultiChannelAppender.

Definitely will need more unit tests.

Thanks for the contribution.  Will use this bug report for continued discussion on this feature.
Comment 4 Ralf Hauser 2008-09-07 22:29:19 UTC
just noticed in a tomcat setting where one thread goes into say appender A1, if that thread spawns a sub-thread, its ouput is not visibly in A1, but again in catalina.out as the "catch-all"...
Comment 5 Ralf Hauser 2008-09-07 22:49:47 UTC
re comment 4 
I guess Thread.local won't work, so probably such threads need to be made multifile-appender aware (which I don't mind)
I guess they'll have to implement an additional abstract interface with a local variable that allows to tell the multifile appender which was the parent's appender
Comment 6 tkpr 2009-01-14 03:41:41 UTC
Hi ,

Thanks for sharing new Developement Actually its a new requirement for me and i got it here .its fit my requirement.Can u please tell how to set the Same using log4j.properties.

i tried the below one but it giving error.
log4j:ERROR No defaultFileName set for the appender named [fcrjlog].

log4j.rootLogger=DEBUG, fcrjlog

log4j.appender.fcrjlog.layout.ConversionPattern=%d %t %p [%c] %m%n
Comment 7 Ralf Hauser 2009-10-01 04:44:27 UTC
see also http://marc.info/?l=log4j-user&m=121252695203831&w=2