logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris McGee (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LOG4J2-1640) RollingFileAppender with CronTriggeringPolicy broken?
Date Mon, 10 Oct 2016 13:52:20 GMT

    [ https://issues.apache.org/jira/browse/LOG4J2-1640?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15562371#comment-15562371
] 

Chris McGee commented on LOG4J2-1640:
-------------------------------------

Certainly. I'll even do one better and provide more detailed info.

> RollingFileAppender with CronTriggeringPolicy broken?
> -----------------------------------------------------
>
>                 Key: LOG4J2-1640
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1640
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.7
>         Environment: Mac OS X 10.11.6 running Eclipse Neon 4.6.0 with JDK 1.8.0_74
>            Reporter: Chris McGee
>            Priority: Blocker
>              Labels: CronTriggeringPolicy, RollingFile, RollingFileAppender, newbie
>
> If this isn't actually a bug, then I apologize for reporting it, but I cannot figure
out how it could be anything else currently. Full disclosure: I am still a newbie.
> I've been using the log4j 2.6.x series for a while, but noticed that the CronTriggeringPolicy
when used with RollingFileAppender causes that infinite rollover bug. I noted that this bug
was to be fixed in 2.7, so I downloaded that the day it was released and replaced the 2.6
version with it. Now, however, without changing anything else in my code nor in my log4j2.xml
file, I am getting exceptions regarding them.
> The stacktrace:
> {noformat}
> 2016-10-10 08:26:14,108 main ERROR Unable to inject fields into builder class for plugin
type class org.apache.logging.log4j.core.appender.RollingFileAppender, element RollingFile.
java.lang.NullPointerException
> 	at org.apache.logging.log4j.core.appender.rolling.CronTriggeringPolicy.rollover(CronTriggeringPolicy.java:133)
> 	at org.apache.logging.log4j.core.appender.rolling.CronTriggeringPolicy.initialize(CronTriggeringPolicy.java:69)
> 	at org.apache.logging.log4j.core.appender.rolling.CompositeTriggeringPolicy.initialize(CompositeTriggeringPolicy.java:52)
> 	at org.apache.logging.log4j.core.appender.rolling.RollingFileManager.initialize(RollingFileManager.java:104)
> 	at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:142)
> 	at org.apache.logging.log4j.core.appender.RollingFileAppender$Builder.build(RollingFileAppender.java:58)
> 	at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:122)
> 	at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:942)
> 	at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:882)
> 	at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:874)
> 	at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:498)
> 	at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:227)
> 	at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:239)
> 	at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:530)
> 	at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:603)
> 	at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:620)
> 	at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:226)
> 	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:242)
> 	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
> 	at org.apache.logging.log4j.LogManager.getContext(LogManager.java:174)
> 	at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:618)
> 	at info.chrismcgee.sky.artdept.ArtDept.<clinit>(ArtDept.java:85)
> 2016-10-10 08:26:14,112 main ERROR Unable to invoke factory method in class class org.apache.logging.log4j.core.appender.RollingFileAppender
for element RollingFile. java.lang.IllegalStateException: No factory method found for class
org.apache.logging.log4j.core.appender.RollingFileAppender
> 	at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.findFactoryMethod(PluginBuilder.java:224)
> 	at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:130)
> 	at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:942)
> 	at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:882)
> 	at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:874)
> 	at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:498)
> 	at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:227)
> 	at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:239)
> 	at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:530)
> 	at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:603)
> 	at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:620)
> 	at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:226)
> 	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:242)
> 	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
> 	at org.apache.logging.log4j.LogManager.getContext(LogManager.java:174)
> 	at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:618)
> 	at info.chrismcgee.sky.artdept.ArtDept.<clinit>(ArtDept.java:85)
> 2016-10-10 08:26:14,113 main ERROR Null object returned for RollingFile in Appenders.
> 2016-10-10 08:26:14,117 main ERROR Unable to locate appender "DailyRoll" for logger config
"root"
> {noformat}
> For reference, the code in my ArtDept.java file on line 85 (as seen in the stacktrace
above) is just a simple field declaration & initialization:
> {code:title=ArtDept.java|borderStyle=solid}
> static final Logger log = LogManager.getLogger(ArtDept.class.getName());
> {code}
> Finally, for reference, my log4j2.xml file:
> {code:xml|title=log4j2.xml|borderStyle=solid}
> <?xml version="1.0" encoding="UTF-8"?>
> <Configuration status="WARN" monitorInterval="30">
>   <Properties>
>     <Property name="filename">logs/artdept.log</Property>
>     <Property name="baseDir">/Volumes/ArtDept/ArtDept/Scripts/sky-artdept/logs</Property>
>   </Properties>
>   <Appenders>
>     <Console name="Console" target="SYSTEM_OUT">
>       <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
>     </Console>
>     <File name="MyFile" fileName="${filename}">
>       <PatternLayout>
>         <pattern>%d %p %C{1.} [%t] %m%n</pattern>
>       </PatternLayout>
>     </File>
>     <RollingFile name="DailyRoll" fileName="${baseDir}/${env:USER}/${date:yyyy}/${date:MM}
- ${date:MMM}/Launcher.log"
>     		filePattern="${baseDir}/${env:USER}/${date:yyyy}/${date:MM} - ${date:MMM}/%d{dd}
- Launcher-%i.log">
>       <PatternLayout>
>         <Pattern>%d %p %C{1.} [%t] %m%n</Pattern>
>       </PatternLayout>
>       <Policies>
>       	<CronTriggeringPolicy schedule="0 0 0 * * ?" evaluateOnStartup="true" />
>       	<SizeBasedTriggeringPolicy size="250 MB" />
>       </Policies>
>     </RollingFile>
>   </Appenders>
>   <Loggers>
>     <Root level="trace">
>       <AppenderRef ref="DailyRoll"/>
>     </Root>
>   </Loggers>
> </Configuration>
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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


Mime
View raw message