I have run into a problem using spring-boot, log4j2 and tomcat.
I have a log4j2 xml config file to use for logging and there is 2 appenders, a console and a file appender.
The problem is that whenever I run the application using main method of the Application class everything works fine, but when I build the war file of the application and deploy it into a standalone tomcat, file appender does not work.
Actually what happens is that console appender works correctly [logs are printed in console] and the file which is specified in log4j2 config file is created but it remains empty.
This is log4j2 config file:
<Properties>
<Property name="LOG_PATTERN">
%d{yyyy-MM-dd HH:mm:ss} %5p ${hostName} --- [%15.15t] %-40.40c{1.} %L : %m%n%ex
</Property>
<Property name="LOG_PATH">
<!-- <absolute_path_to_log_file_directory> -->
</Property>
</Properties>
<Appenders>
<Console name="ConsoleAppender" target="SYSTEM_OUT">
<PatternLayout pattern="${LOG_PATTERN}"/>
</Console>
<RollingFile name="FileAppender"
fileName="${LOG_PATH}/mylogfile.log"
filePattern="${LOG_PATH}/mylogfile-%d{yyyy-MM-dd}-%i.log">
<PatternLayout>
<Pattern>${LOG_PATTERN}</Pattern>
</PatternLayout>
<Policies>
<TimeBasedTriggeringPolicy interval="1" />
</Policies>
</RollingFile>
</Appenders>
<Loggers>
<Logger name="my.package.name" level="debug" additivity="false">
<AppenderRef ref="FileAppender" />
<AppenderRef ref="ConsoleAppender" />
</Logger>
<Root level="info">
<AppenderRef ref="ConsoleAppender" />
<AppenderRef ref="FileAppender" />
</Root>
</Loggers>
Any help in this matter is appreciated.