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 "Austin Huck (JIRA)" <ji...@apache.org> on 2017/03/02 18:48:45 UTC

[jira] [Updated] (LOG4J2-1833) NullPointerException using fileName property of RollingFile Appender with DirectWriteRolloverStrategy

     [ https://issues.apache.org/jira/browse/LOG4J2-1833?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Austin Huck updated LOG4J2-1833:
--------------------------------
    Description: 
When using a {{RollingFileAppender}} with a {{DirectWriteRolloverStrategy}} if the _fileName_ property of the appender is set, rollover fails with a {{NullPointerException}}. If the _fileName_ attribute is not preset logging works as intended.

Configuration that produces this error:
{code:title=log4j2.xml|borderStyle=solid}
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn" name="MyApp" packages="">
    <Properties>
        <Property name="baseDir">C:/logs</Property>
    </Properties>
    <Appenders>
        <RollingFile name="RollingFile" fileName="${baseDir}/app.log"
                     filePattern="${baseDir}/app-%d{yyyy-MM-dd'T'HH_mm_ss}.log">
            <PatternLayout pattern="%d %p %c{1.} [%t] %m%n" />
            <TimeBasedTriggeringPolicy interval="10"/>
            <DirectWriteRolloverStrategy>
                <Delete basePath="${baseDir}">
                    <IfFileName glob="app-*.log" />
                    <IfAccumulatedFileCount exceeds="10" />
                </Delete>
            </DirectWriteRolloverStrategy>
        </RollingFile>
    </Appenders>
    <Loggers>
        <Root level="trace">
            <AppenderRef ref="RollingFile"/>
        </Root>
    </Loggers>
</Configuration>
{code}

  was:
When using a {{RollingFileAppender}} with a {{DirectWriteRolloverStrategy}} if the _fileName_ property of the appender is set rollover fails with a {{NullPointerException}}. If the _fileName_ attribute is not preset logging works as intended.

Configuration that produces this error:
{code:title=log4j2.xml|borderStyle=solid}
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn" name="MyApp" packages="">
    <Properties>
        <Property name="baseDir">C:/logs</Property>
    </Properties>
    <Appenders>
        <RollingFile name="RollingFile" fileName="${baseDir}/app.log"
                     filePattern="${baseDir}/app-%d{yyyy-MM-dd'T'HH_mm_ss}.log">
            <PatternLayout pattern="%d %p %c{1.} [%t] %m%n" />
            <TimeBasedTriggeringPolicy interval="10"/>
            <DirectWriteRolloverStrategy>
                <Delete basePath="${baseDir}">
                    <IfFileName glob="app-*.log" />
                    <IfAccumulatedFileCount exceeds="10" />
                </Delete>
            </DirectWriteRolloverStrategy>
        </RollingFile>
    </Appenders>
    <Loggers>
        <Root level="trace">
            <AppenderRef ref="RollingFile"/>
        </Root>
    </Loggers>
</Configuration>
{code}


> NullPointerException using fileName property of RollingFile Appender with DirectWriteRolloverStrategy
> -----------------------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-1833
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1833
>             Project: Log4j 2
>          Issue Type: Bug
>    Affects Versions: 2.8.1
>         Environment: Windows 7 64-bit JVM
>            Reporter: Austin Huck
>            Priority: Minor
>
> When using a {{RollingFileAppender}} with a {{DirectWriteRolloverStrategy}} if the _fileName_ property of the appender is set, rollover fails with a {{NullPointerException}}. If the _fileName_ attribute is not preset logging works as intended.
> Configuration that produces this error:
> {code:title=log4j2.xml|borderStyle=solid}
> <?xml version="1.0" encoding="UTF-8"?>
> <Configuration status="warn" name="MyApp" packages="">
>     <Properties>
>         <Property name="baseDir">C:/logs</Property>
>     </Properties>
>     <Appenders>
>         <RollingFile name="RollingFile" fileName="${baseDir}/app.log"
>                      filePattern="${baseDir}/app-%d{yyyy-MM-dd'T'HH_mm_ss}.log">
>             <PatternLayout pattern="%d %p %c{1.} [%t] %m%n" />
>             <TimeBasedTriggeringPolicy interval="10"/>
>             <DirectWriteRolloverStrategy>
>                 <Delete basePath="${baseDir}">
>                     <IfFileName glob="app-*.log" />
>                     <IfAccumulatedFileCount exceeds="10" />
>                 </Delete>
>             </DirectWriteRolloverStrategy>
>         </RollingFile>
>     </Appenders>
>     <Loggers>
>         <Root level="trace">
>             <AppenderRef ref="RollingFile"/>
>         </Root>
>     </Loggers>
> </Configuration>
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

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