Today I spent way too many hours fixing a bug I ran across while getting Quartz integrated into a Java Webapp running on Tomcat with integrated log4j. The Quartz api uses slf4j logging and Quartz was throwing null pointer exceptions when starting up relating to logging. Below is the solution in my particular case. I hope this helps someone else!
log4j:ERROR Error occured while converting date.
java.lang.NullPointerException
at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:488)
at java.lang.StringBuffer.append(StringBuffer.java:302)
at org.apache.log4j.helpers.ISO8601DateFormat.format(ISO8601DateFormat.java:132)
at java.text.DateFormat.format(DateFormat.java:314)
at org.apache.log4j.helpers.PatternParser$DatePatternConverter.convert(PatternParser.java:444)
at org.apache.log4j.helpers.PatternConverter.format(PatternConverter.java:64)
at org.apache.log4j.PatternLayout.format(PatternLayout.java:503)
at org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:301)
at org.apache.log4j.WriterAppender.append(WriterAppender.java:159)
at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:230)
at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:65)
at org.apache.log4j.Category.callAppenders(Category.java:203)
at org.apache.log4j.Category.forcedLog(Category.java:388)
at org.apache.log4j.Category.log(Category.java:853)
at org.slf4j.impl.Log4jLoggerAdapter.debug(Log4jLoggerAdapter.java:204)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:595)
[] DEBUG org.quartz.simpl.SimpleThreadPool WorkerThread is shut down.
The solution is to replace "ISO8601" in the following log4j.xml file with "yyyy-MM-dd HH:mm:ss.SSS". AHHHHRRRRRRRR!
<appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%d{ISO8601}] %-5p %c %m %n" />
</layout>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="LevelMin" value="WARN"/>
<param name="LevelMax" value="FATAL"/>
</filter>
</appender>
Nice ! Saved me a couple hours googling ! Thanks.
ReplyDeleteThank you!!!
ReplyDeletethanks ! worked like a dream!
ReplyDeleteoh wow you have got to be kidding...
ReplyDeleteNote that the doco states that custom formats don't perform as well as the built in formats.
ReplyDelete