• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Tomcat log truncate issue  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am facing a weird situation across all the environments (DEV/UAT/PROD) which i support.

The tomcat support logs gets auto truncate during mid of the day without keeping a backup. There is no consistent time stamp at which it truncates.
1. We are using log4j time based rolling, which is suppose to roll the log file at the end of the day.
2. Cron job is used to move this old log file to Archive.

Both of the above steps are working perfectly good.

But while the logs are getting rolled during the day, it truncates suddenly and i can see that the time stamp fo the start of the file changes.

Below snippet from log4j

<appender name="SUPPORT" class="org.apache.log4j.rolling.RollingFileAppender">
               <param name="append" value="true" />
               <param name="encoding" value="UTF-8" />
               <rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
                       <param name="FileNamePattern" value="${OTS_HOME}/logs/tomcat/support-${INSTANCE}-%d.log" />
               </rollingPolicy>
               <layout class="org.apache.log4j.PatternLayout">
                       <param name="ConversionPattern" value="%d [%t] %-5p %c %M - %m%n" />
               </layout>
       </appender>

Appreciate if anyone can help. I suspect if there is any known issue with Tomcat.
apache-tomcat-7.0.30. This is the version of tomcat.

 
Bartender
Posts: 19993
95
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, Vandana!

Tomcat itself does not log using log4j unless you custom-build a Tomcat with that capability. Logging for webapps is entirely managed by each webapp with no co-ordination with the Tomcat server.

So this would be a log4j problem.

The first thing that comes to mind is that the clock managing the logfile truncations is probably UTC, since midnight UTC would be around midday in much of Asia. The reason why the precise time varies could be as simple as statistical variations in the last logged message time before rollover and an opportunistic rollover mechanism. That is one, that rolls over when it's convenient and near rollover time, rather than precisely on schedule.

You might also want to check the log4j docs and see if there's a parameter that can set the rollover time and possibly time precision options.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!