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 Jacob Kjome <ho...@visi.com> on 2004/12/10 06:48:05 UTC
FixedWindowRollingPolicy still broken
At 01:27 PM 12/9/2004 +0000, you wrote:
>ceki 2004/12/09 05:27:21
> if (fileNamePatternStr != null) {
> + fileNamePattern = new FileNamePattern(fileNamePatternStr);
> determineCompressionMode();
> }
>
Ceki,
FixedWindowRollingPolicy is still broken. Try providing a config file
without specifying the "fileNamePattern" param and watch it blow up. Note
the following code...
if (fileNamePatternStr != null) {
fileNamePattern = new FileNamePattern(fileNamePatternStr);
determineCompressionMode();
}
IntegerTokenConverter itc = fileNamePattern.getIntegerTokenConverter();
You only initialize the fileNamePattern object only if the string was
provided. If it wasn't, it isn't initialized. And then in the very next
line of code, you use the fileNamePattern object, resulting in a
NullPointerException. It is then used at least 7 other times in the
class. Why haven't you taken the same approach here as you did in
TimeBasedRollingPolicy as I recommended yesterday?....
public void activateOptions() {
// find out period from the filename pattern
if (fileNamePatternStr != null) {
fileNamePattern = new FileNamePattern(fileNamePatternStr);
determineCompressionMode();
} else {
getLogger().warn(FNP_NOT_SET);
getLogger().warn(SEE_FNP_NOT_SET);
throw new IllegalStateException(FNP_NOT_SET + SEE_FNP_NOT_SET);
}
.....
.....
It is obvious that both the activeFileName the fileNamePattern params must
be required in FixedWindowRollingPolicy. Here's another stack trace to
prove it (after commenting out the "fileNamePattern" param in my config
file)....
java.lang.ExceptionInInitializerError
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at java.lang.Class.newInstance0(Class.java:308)
at java.lang.Class.newInstance(Class.java:261)
at org.apache.catalina.startup.Bootstrap.init(Bootstrap.java:201)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:386)
Caused by: org.apache.commons.logging.LogConfigurationException:
java.lang.ExceptionInInitializerError (Caused by
java.lang.ExceptionInInitializerError)
at
org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:538)
at
org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
at
org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
at
org.apache.catalina.core.StandardService.<clinit>(StandardService.java:53)
... 8 more
Caused by: java.lang.ExceptionInInitializerError
at org.apache.log4j.Logger.getLogger(Logger.java:64)
at
org.apache.commons.logging.impl.Log4JLogger.getLogger(Log4JLogger.java:229)
at
org.apache.commons.logging.impl.Log4JLogger.<init>(Log4JLogger.java:65)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at
org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
... 12 more
Caused by: java.lang.NullPointerException
at
org.apache.log4j.rolling.FixedWindowRollingPolicy.activateOptions(FixedWindowRollingPolicy.java:102)
at
org.apache.joran.action.NestComponentIA.end(NestComponentIA.java:129)
at org.apache.joran.Interpreter.callEndAction(Interpreter.java:234)
at org.apache.joran.Interpreter.endElement(Interpreter.java:138)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown
Source)
at
org.apache.xerces.impl.dtd.XMLDTDValidator.endNamespaceScope(Unknown Source)
at
org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at
org.apache.log4j.joran.JoranConfigurator.doConfigure(JoranConfigurator.java:181)
at
org.apache.log4j.joran.JoranConfigurator.doConfigure(JoranConfigurator.java:159)
at
org.apache.log4j.joran.JoranConfigurator.doConfigure(JoranConfigurator.java:100)
at
org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:534)
at
org.apache.log4j.helpers.IntializationUtil.initialConfiguration(IntializationUtil.java:85)
at org.apache.log4j.LogManager.<clinit>(LogManager.java:113)
... 20 more
Jake
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org
Re: FixedWindowRollingPolicy still broken
Posted by Jacob Kjome <ho...@visi.com>.
Quoting Ceki Gülcü <ce...@qos.ch>:
> In short, I forgot the patently obvious. FileNamePattern is always
> required whereas ActiveFileName is only required for
> FixedWindowRollingPolicy but not for TimeBasedRollingPolicy.
>
> As you proposed, the approach taken in TimeBasedRollingPolicy should
> also be applied to FixedWindowRollingPolicy. Would you care to commit
> these changes? Note that the javadocs as well as
> http://logging.apache.org/log4j/docs/codes.html would also need to be
> updated.
>
> Many thanks in advance,
I'll try to get it done sometime this weekend. Can't do it from work.
>
> --
> Ceki Gülcü
>
> ps. Thanks for bearing with me.
I appreciate all your hard work on Log4j. Hopefully I haven't been too
overbearing.
later,
Jake
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org
Re: FixedWindowRollingPolicy still broken
Posted by Ceki Gülcü <ce...@qos.ch>.
At 06:48 AM 12/10/2004, Jacob Kjome wrote:
>Ceki,
>
>FixedWindowRollingPolicy is still broken. Try providing a config file
>without specifying the "fileNamePattern" param and watch it blow up. Note
>the following code...
>
> if (fileNamePatternStr != null) {
> fileNamePattern = new FileNamePattern(fileNamePatternStr);
> determineCompressionMode();
> }
>
> IntegerTokenConverter itc = fileNamePattern.getIntegerTokenConverter();
>
>
>You only initialize the fileNamePattern object only if the string was
>provided. If it wasn't, it isn't initialized. And then in the very next
>line of code, you use the fileNamePattern object, resulting in a
>NullPointerException. It is then used at least 7 other times in the
>class. Why haven't you taken the same approach here as you did in
>TimeBasedRollingPolicy as I recommended yesterday?....
>
> public void activateOptions() {
> // find out period from the filename pattern
> if (fileNamePatternStr != null) {
> fileNamePattern = new FileNamePattern(fileNamePatternStr);
> determineCompressionMode();
> } else {
> getLogger().warn(FNP_NOT_SET);
> getLogger().warn(SEE_FNP_NOT_SET);
> throw new IllegalStateException(FNP_NOT_SET + SEE_FNP_NOT_SET);
> }
> .....
> .....
In short, I forgot the patently obvious. FileNamePattern is always
required whereas ActiveFileName is only required for
FixedWindowRollingPolicy but not for TimeBasedRollingPolicy.
As you proposed, the approach taken in TimeBasedRollingPolicy should
also be applied to FixedWindowRollingPolicy. Would you care to commit
these changes? Note that the javadocs as well as
http://logging.apache.org/log4j/docs/codes.html would also need to be
updated.
Many thanks in advance,
--
Ceki Gülcü
ps. Thanks for bearing with me.
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org