'Not able to fetch ${catalina.base}, system property not working in log4j2.xml?

Previously we had a log4j 1.x compatible xml format which was having this Rolling file appender configured-

<appender name="ALL" class="org.apache.log4j.RollingFileAppender">
        <param name="File" value="${catalina.base}/logs/trw.log" />
        <param name="Append" value="true" />
        <param name="MaxFileSize" value="4096KB" />
        <param name="MaxBackupIndex" value="10" />
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d %p [%t] %C{1}:%L - %m%n" />
        </layout>
    </appender>

Now I have changed it to the new log4j2.xml format where based on my research the catalina.base becomes like so -

    <RollingFile name="ALL" fileName="${sys:catalina.base}/logs/trw.log"
                     filePattern="${sys:catalina.base}/logs/trw_%i.log"
                     append ="true">
            <PatternLayout pattern="%d %p [%t] %c{1}:%L - %m%n"/>
            <Policies>
                <SizeBasedTriggeringPolicy size="4096KB" />
            </Policies>
            <DefaultRolloverStrategy max="10"/>
        </RollingFile>

But when I run a test file which uses this logging configuration, the xml file is found and loaded and all is going well but instead of finding the system variable cataline.base it creates a folder ${sys:catalina.base} and puts the log under it. My question is that - is this the expected behaviour ? Does log4j2.xml config try to search for the system property and if not found just creates a folder with that name ? This config is in a web-application which runs on TomCat 7, spring 3.1 and servlet 2.5. Logs are getting generated as expected but only folder name seems to be the issue.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source