Hi Anders,
Here is a small test program:
import org.apache.log4j.*;
import org.apache.log4j.config.*;
import java.beans.*;
public class R {
static public void main(String[] args) {
try {
BeanInfo bi = Introspector.getBeanInfo(RollingFileAppender.class);
PropertyDescriptor[] props = bi.getPropertyDescriptors();
for(int i = 0; i < props.length; i++) {
System.out.println("Property name: "+ props[i].getName()+
", type: "+props[i].getPropertyType());
System.out.println("Setter method: "+ props[i].getWriteMethod()+"\n")
}
} catch(Exception e) {
e.printStackTrace();
}
}
}
It spits out:
Property name: name, type: class java.lang.String
Setter method: public void org.apache.log4j.AppenderSkeleton.setName(java.lang.String)
Property name: maxBackupIndex, type: int
Setter method: public void org.apache.log4j.RollingFileAppender.setMaxBackupIndex(int)
Property name: filter, type: class org.apache.log4j.spi.Filter
Setter method: null
Property name: append, type: boolean
Setter method: public void org.apache.log4j.FileAppender.setAppend(boolean)
Property name: file, type: class java.lang.String
Setter method: public void org.apache.log4j.FileAppender.setFile(java.lang.String)
Property name: maxFileSize, type: long <---- Note this
Setter method: public void org.apache.log4j.RollingFileAppender.setMaxFileSize(long)
<--- and this
Property name: writer, type: class java.io.Writer
Setter method: public synchronized void
org.apache.log4j.WriterAppender.setWriter(java.io.Writer)
Property name: class, type: class java.lang.Class
Setter method: null
Property name: firstFilter, type: class org.apache.log4j.spi.Filter
Setter method: null
Property name: threshold, type: class org.apache.log4j.Priority
Setter method: public void
org.apache.log4j.AppenderSkeleton.setThreshold(org.apache.log4j.Priority)
Property name: errorHandler, type: interface org.apache.log4j.spi.ErrorHandler
Setter method: public synchronized void
org.apache.log4j.WriterAppender.setErrorHandler(org.apache.log4j.spi.ErrorHandler)
Property name: layout, type: class org.apache.log4j.Layout
Setter method: public void
org.apache.log4j.AppenderSkeleton.setLayout(org.apache.log4j.Layout)
Property name: immediateFlush, type: boolean
Setter method: public void org.apache.log4j.WriterAppender.setImmediateFlush(boolean)
Property name: optionStrings, type: class [Ljava.lang.String;
(This, when the setMaxFileSize(long) in RollingFileAppender is put back in.)
I am using
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
on Windows 2000.
In any case, the setMaxFileSize(String) setter is invisible. I suppose the rest of the
problem is clear. The wrong settter method is used for the maxFileSize property which
causes a NumberFormatException, etc, etc.
The only solution I can think of apart from removing setMaxFileSize(long), is to write
a custom RollingFileAppenderBeanInfo class to circumvent the problem... Cheers, Ceki
At 04:57 19.04.2001 +0200, Anders Kristensen wrote:
>Actually it seems that the JavaBeans introspector returns the String
>setter when a class has something like
>
> setMaxFileSize(long)
> setMaxFileSize(String)
>
>so I don't know why setMaxFileSize(long) had to be commented out?
>
>Cheers,
>Anders
>
>
>Ceki Gülcü wrote:
>>
>> Aaaaaaaaaaaaah!
>>
>> There are two versions of setMaxFileSize in RollingFileAppender:
>>
>> setMaxFileSize(long)
>>
>> and
>>
>> setMaxFileSize(String)
>>
>> The problem is that the JabaBeans Introspector returns the former when asked for
>setter methods in RollingFileAppender. However, this causes problems when log4j is
>configured using scripts because the
>> max file size is specified using units as in 1048576, 1024KB, or 1MB but 1MB is not
>a valid number calling setMaxFileSize(long) fails.
>>
>> The only solution I can think of is to add a custom BeanInfo class for
>RollingFileAppender where the setMaxFileSize(long) setter is removed. This is a bit
>cumbersome but can be done.
>>
>> Well, I never imagined that someone was using the removed method. I guess I was
>wrong. I'll see what I can do.
>>
>> Anders, do you have a better idea? Cheers, Ceki
>>
>> ps: Sam, thanks for the info.
>>
>> At 05:32 18.04.2001 -0400, Sam Ruby wrote:
>> >Why was setMaxFileSize(long) in org.apache.log4j.RollingFileAppender removed?
>> >
>>
>>http://jakarta.apache.org/cvsweb/index.cgi/jakarta-log4j/src/java/org/apache/log4j/RollingFileAppender.java.diff?r1=1.8&r2=1.9&diff_format=h
>> >
>> >In a few hours, you should be able to see the failure that this produces at:
>> >
>> >http://jakarta.apache.org/builds/gump/2001-04-18/jakarta-velocity.html
>> >
>> >- Sam Ruby
>> >
>> >
>> >---------------------------------------------------------------------
>> >To unsubscribe, e-mail: [EMAIL PROTECTED]
>> >For additional commands, e-mail: [EMAIL PROTECTED]
>>
>> --
>> Ceki Gülcü
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
--
Ceki Gülcü
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]