On Oct 9, 2006, at 3:03 AM, Bender Heri wrote:

Hi all

After having thought during the weekend I think Patrick's suggestion of Decorator Pattern would be the easiest way to go.

Pro:
- The enhancement applies to all FileAppender
- There is no need to touch the code of the existing file appenders. They work the same way as until now (except the append property is always true)

Contra:
- A new feature in xml config would be needed (see below)
- Since property config is no more supported the MultiFileAppender would only be available with xml configurations

A proposal for configuring the MultiFileAppender with new tag "classparam":

<appender name="Multi_Appender" class="org.apache.log4j.MultiFileAppender"> <classparam name="fileAppender" class="org.apache.log4j.DailyRollingFileAppender">
            <param name="file" value="myLog.log"/>
            <param name="DatePattern" value="yyyy-MM-dd"/>
            ...
        </classparam>
        <layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{dd.MM.yy HH:mm:ss.SSS} %m%n"/>
        </layout>
<classparam name="fileNamePolicy" class="my.company.LogFileNameBuilder"/>
    </appender>

The idea is that a param of a configured item can be a class as well, with own properties. The configurator would recursively instantiate the enclosed classes and then call the setFileAppender () of the MultiFileAppender.

Heri



I'm wary of that best approach. There are a couple of reasons that strike me:

1. I think that the new appender should be able to work in both log4j 1.2 and 1.3 to be of the most benefit to the community. If the appender requires modification of the configurator code, then it is effectively limited to log4j 1.3.

2. I suspect that setFileAppender would have concurrency issues. A lot of the set calls are designed assuming that there will be log requests until after activateOptions is called. If a MultiFileAppender called setFileAppender as part of the event dispatching code, I'm guessing a lot of bad things could happen in certain circumstances.

If MultiFileAppender with pluggable FileNamePolicy can't be effectively configured with the log4j 1.2 configurators, we might create a couple of "prepackaged" MultiFileAppender derivatives with fixed FileNamePolicy's classes.

Getting a late start, but I should be at ApacheCON tonight and will work on this tomorrow.



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

Reply via email to