Log rotation of Tomcat logs fails on Windows

  • 7017790
  • 30-Jun-2016
  • 05-Jul-2016

Environment

NetIQ Identity Manager 4.5.x
Microsoft Windows Server 2012R2

Situation

When Identity Apps 4.5 is installed on Windows 2012 the Tomcat catalina.out log doesn't always roll after 24 hours. The OSP log rolls correctly but not the catalina.out. This problem occurs when using the Integreated Installer or doing a framework install.

Resolution

The Identity Applications use log4j DailyRollingFileAppender for rolling the catalina.out file every day. Log4j DailyRollingFileAppender renames the day’s log file at the end of the day. This runs into file contention problems in Windows, and the renaming regularly fails. This problem is not caused by Identity Manager but by Apache's Log4j instead.


To fix this issue, Log4j released a separate Log4j Extras patch. They can be found at:

http://archive.apache.org/dist/logging/log4j/1.2.17/log4j-1.2.17.jar
http://archive.apache.org/dist/logging/log4j/extras/1.2.17/apache-log4j-extras-1.2.17.jar

Steps to apply the fix:

1) Stop tomcat.

2) Remove the existing tomcat/lib/log4j.jar file.(Take a backup before deleting)

3) Download the log4j-1.2.17.jar file and copy into tomcat/lib/ folder.

4) Download the apache-log4j-extras jar file and copy into tomcat/lib/ folder.

5) Change the tomcat/lib/log4j.properties file with the following content:

# Define all the appenders
log4j.appender.CATALINA = org.apache.log4j.rolling.RollingFileAppender
log4j.appender.CATALINA.File = C:\\NetIQ\\IdentityManager\\apps\\tomcat\\logs\\catalina.out            
log4j.appender.CATALINA.Append = true
log4j.appender.CATALINA.Encoding = UTF-8
log4j.appender.CATALINA.RollingPolicy=org.apache.log4j.rolling.TimeBasedRollingPolicy
log4j.appender.CATALINA.RollingPolicy.ActiveFileName=C:\\NetIQ\\IdentityManager\\apps\\tomcat\\logs\\catalina.out                 
log4j.appender.CATALINA.RollingPolicy.FileNamePattern=C:\\NetIQ\\IdentityManager\\apps\\tomcat\\logs\\catalina.out.%d.log

# Roll-over the log once per day
log4j.appender.CATALINA.DatePattern = '.'yyyy-MM-dd'.log'
log4j.appender.CATALINA.layout = org.apache.log4j.PatternLayout
log4j.appender.CATALINA.layout.ConversionPattern = %d [%t] %-5p %c- %m%n


NOTE: If Tomcat is installed in a different path, specify the right path to the catalina.out file

6) Start tomcat.


Since this issue is Windows specific, at this moment it's only recommended to apply this patch on Windows platforms and not on Linux.


Additional Information