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 Andreas Fester <An...@gmx.de> on 2005/10/02 23:17:44 UTC

RollingFileAppender

Hi,

I played with the RollingFileAppender in log4j 1.3 today, mainly
because I started some work on the RollingFileAppender in log4cxx.
Just to be sure:

- The old RollingFileAppender (outside the rolling package)
   is not supported anymore, not even as a delegate to support
   the old property configuration?

- I tried to configure the new RollingFileAppender like

log4j.appender.testAppender=org.apache.log4j.rolling.RollingFileAppender
log4j.appender.testAppender.triggeringPolicy=org.apache.log4j.rolling.SizeBasedTriggeringPolicy
log4j.appender.testAppender.file=RFA-test1.log

   but it seems that properties can still only be Strings, especially
   if their setter begins with "set" (there seems to be a similar
   mechanism for "add..." methods). Complex types (like layout)
   must be handled specially in the PropertyConfigurator?

   This again would mean that configuring the RollingFileAppender
   is not yet possible with the PropertyConfigurator?

   Would it be a proper solution to add special runtime instanciation
   of the triggeringPolicy class to the PropertyConfigurator, or is
   a smarter method intended (like looking for a setter which takes
   an Object, and trying to instanciate a class with the given property
   value)?

Just want to make sure that I add a patch which was sent for log4cxx
in the most log4j-alike way...

Thanks,

	Andreas

-- 
Andreas Fester
mailto:andreas@littletux.net
WWW: http://www.littletux.net
ICQ: 326674288

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Re: RollingFileAppender

Posted by Andreas Fester <An...@gmx.de>.
[...]
> That is my understanding.  I believe that filters are also not  
> configurable from property files.

Wouldnt it be useful to be able to do this?
The attached patch adds a mechanism to the PropertySetter which
tries to instanciate a class from the property value, if the parameter
of the setter is not a primitive type. With this patch, I was able
to configure the RollingFileAppender as follows:

log4j.appender.testAppender=org.apache.log4j.rolling.RollingFileAppender
log4j.appender.testAppender.triggeringPolicy=org.apache.log4j.rolling.SizeBasedTriggeringPolicy
log4j.appender.testAppender.triggeringPolicy.maxFileSize=100
log4j.appender.testAppender.rollingPolicy=org.apache.log4j.rolling.FixedWindowRollingPolicy
log4j.appender.testAppender.rollingPolicy.fileNamePattern=RFA-test%i.log
log4j.appender.testAppender.rollingPolicy.activeFileName=RFA-test.log
log4j.appender.testAppender.Append=false
log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.testAppender.layout.ConversionPattern=%m\n

Drawback of my fast and dirty solution is that part of the
PropertyConfigurator behaviour is duplicated in the PropertySetter,
to allow configuring the sub component.

Regards,

	Andreas

-- 
Andreas Fester
mailto:andreas@littletux.net
WWW: http://www.littletux.net
ICQ: 326674288

Re: RollingFileAppender

Posted by Curt Arnold <ca...@apache.org>.
On Oct 2, 2005, at 4:17 PM, Andreas Fester wrote:


> Hi,
>
> I played with the RollingFileAppender in log4j 1.3 today, mainly
> because I started some work on the RollingFileAppender in log4cxx.
> Just to be sure:
>
> - The old RollingFileAppender (outside the rolling package)
>   is not supported anymore, not even as a delegate to support
>   the old property configuration?
>
>

The o.a.log4j.RollingFileAppender was removed from the CVS HEAD, but  
a delegating implementation was added back for compatibility with  
existing configuration files.  The delegating implementation has not  
appeared in any log4j 1.3 alpha release.  The delegating  
implementation is configuration compatible with the old  
implementation but user-supplied class that extended  
o.a.log4j.RollingFileAppender will likely fail to load and will  
surely not perform as expected.  The delegating implementation should  
be more robust that the log4j 1.2 implementation.  Not particularly  
happy with the situation, maybe should leave the old buggy o.a.l.RFA  
in the code for extension and have the configurators load a  
delegating RFA if it sees the old class name.



> - I tried to configure the new RollingFileAppender like
>
> log4j.appender.testAppender=org.apache.log4j.rolling.RollingFileAppend 
> er
> log4j.appender.testAppender.triggeringPolicy=org.apache.log4j.rolling. 
> SizeBasedTriggeringPolicy
> log4j.appender.testAppender.file=RFA-test1.log
>
>   but it seems that properties can still only be Strings, especially
>   if their setter begins with "set" (there seems to be a similar
>   mechanism for "add..." methods). Complex types (like layout)
>   must be handled specially in the PropertyConfigurator?
>
>   This again would mean that configuring the RollingFileAppender
>   is not yet possible with the PropertyConfigurator?
>

That is my understanding.  I believe that filters are also not  
configurable from property files.





---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org