Details
-
Bug
-
Resolution: Unresolved
-
Major
-
1.1.2
-
Windows 7 x64, Tomcat 7
Description
I want to do log rollover on application start. I'm using this code:
Bar.java
JoranConfigurator configurator = new JoranConfigurator(); configurator.setContext(context); context.reset(); configurator.doConfigure(u); @SuppressWarnings({ "rawtypes", "unchecked" }) HashMap<String, Appender<?>> appenderBag = (HashMap) configurator .getInterpretationContext() .getObjectMap().get(ActionConst.APPENDER_BAG); for (Appender<?> a : appenderBag.values()) { System.out.println("Rolling file for " + a.getName()); if (a instanceof RollingFileAppender) { System.out.println("really Rolling file for " + a.getName()); try { ((RollingFileAppender<?>)a).rollover(); } catch (Exception e) { e.printStackTrace(); } } }
I get this exception:
Bar.java
java.lang.NullPointerException
at ch.qos.logback.core.rolling.helper.FileFilterUtil.afterLastSlash(FileFilterUtil.java:46)
at ch.qos.logback.core.rolling.TimeBasedRollingPolicy.rollover(TimeBasedRollingPolicy.java:149)
at ch.qos.logback.core.rolling.RollingFileAppender.attemptRollover(RollingFileAppender.java:158)
at ch.qos.logback.core.rolling.RollingFileAppender.rollover(RollingFileAppender.java:137)
at config.log.LoggerUtils.loadLoggingConfig(LoggerUtils.java:73)
at config.ProjectContextListener.contextInitialized(ProjectContextListener.java:52)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:672)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1862)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
When rollover happens on it's own (as defined in .xml file) everything is OK. I think this is a bug
My XML:
<appender name="warnings-to-file" class="ch.qos.logback.core.rolling.RollingFileAppender"> <filter class="config.log.ActionMarkerFilter"> <OnMatch>DENY</OnMatch> <OnMismatch>NEUTRAL</OnMismatch> </filter> <filter class="config.log.TimingMarkerFilter"> <OnMatch>DENY</OnMatch> <OnMismatch>NEUTRAL</OnMismatch> </filter> <file>${LOG_PATH}/warnings.log</file> <encoder> <pattern>%d{HH:mm:ss} %-4level %msg%n</pattern> </encoder> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>${LOG_PATH}/warnings-%d{yyyy-MM-dd}.%i.log</fileNamePattern> <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> <maxFileSize>100MB</maxFileSize> <elapsedPeriodsFileName>warnings.log</elapsedPeriodsFileName> </timeBasedFileNamingAndTriggeringPolicy> </rollingPolicy> </appender>
Attachments
Issue Links
- relates to (out)
-
LOGBACK-204 file appender that rolls on startup
- Open