Skip to content
Advertisement

Log4j RollingFileAppender has odd behavior when using the Log4j 1.x bridge

While I migrate to log4j2, I have configured my Tomcat web application to use the Log4j 1.x bridge. I followed the Migration guide here: https://logging.apache.org/log4j/2.x/manual/migration.html

I continue to use my existing log4j.properties file which look like this:

JavaScript

This successfully creates my log file and rolls over at 10KB.

I am having an issues that I can’t explain. Here are the files in my log directory:

JavaScript

I get a log file named for the current day. I’ve experimented and it looks like the RollingFileAppender is also rolling at the end of each day. It didn’t do this before using the bridge. Any idea why this is happening and how to stop it?

Advertisement

Answer

Edit: This was a bug and was fixed in version 2.17.2.

This is a bug and you should report it. The RollingFileAppenderBuilder (cf. source code) has a filePattern containing a date instead of a number:

JavaScript

and hence it behaves more like the DailyRollingFileAppender, than a Log4j 1.x RollingFileAppender.

As a workaround you can use the older Log4j1ConfigurationFactory by setting these system properties:

JavaScript
Advertisement