I have both a dekstop application and a tomcat web application that
write to a log file using log4j2. I also then have the log4j2.xml
configuration file. The file it is writing to is held within a folder
that as stored as an environment variable. The log4j2.xml file thus
looks like this,
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" monitorInterval="30">
<Properties>
<Property name="logdir">${env:FOO}/log</Property>
<Property name="msgformat">%d{yyyy-MM-dd HH:mm:ss.SSS}{GMT+0}
[%t] %-5level %logger{36} - %msg%n</Property>
</Properties>
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="${msgformat}"/>
</Console>
<RollingFile name="ERROR_FILE" fileName="${logdir}/error.log"
filePattern="${logdir}/error-%i.log">
<PatternLayout pattern="${msgformat}"/>
<Policies>
<SizeBasedTriggeringPolicy size="20 MB"/>
</Policies>
<DefaultRolloverStrategy max="10"/>
</RollingFile>
<RollingFile name="EVENT_FILE" fileName="${logdir}/event.log"
filePattern="${logdir}/event-%i.log">
<PatternLayout pattern="${msgformat}"/>
<Policies>
<SizeBasedTriggeringPolicy size="20 MB"/>
</Policies>
<DefaultRolloverStrategy max="10"/>
</RollingFile>
</Appenders>
<Loggers>
<Logger name="foo.utils.footest" level="trace"
additivity="false">
<AppenderRef ref="Console"/>
</Logger>
<Logger name="foo.foologger" level="trace"
additivity="false">
<AppenderRef ref="ERROR_FILE" level="WARN"/>
<AppenderRef ref="EVENT_FILE" level="TRACE"/>
</Logger>
<Logger name="foo" level="info"
additivity="false">
<AppenderRef ref="ERROR_FILE" level="WARN"/>
<AppenderRef ref="EVENT_FILE" level="TRACE"/>
</Logger>
<Root level="trace">
<AppenderRef ref="Console" />
</Root>
</Loggers>
</Configuration>
However when I try to use that log4j2.xml with the Tomcat webapp it
just created a ${env:FOO} folder in the file-system directory. However
of I replace env with sys then the webapp writes to the log file but
now when the Desktop application tries to use that log4j2.xml with sys
it make a ${sys:FOO} folder in the file-system directory. Why might
this be happening, where when I use sys with the desktop app it can't
find the environment variable but the webapp can and when I use env
the webapp can't find the environment variable but the desktop app
can? I am using log4j2 with tomcat 7.0.57 with RHEL 6.6
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]