This week's book giveaway is in the NodeJS forum.
We're giving away four copies of Serverless Applications with Node.js and have Slobodan Stojanovic & Aleksandar Simovic on-line!
See this thread for details.
Win a copy of Serverless Applications with Node.js this week in the NodeJS forum!
  • 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 ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

Tomcat log truncate issue  RSS feed

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

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" />
               <layout class="org.apache.log4j.PatternLayout">
                       <param name="ConversionPattern" value="%d [%t] %-5p %c %M - %m%n" />

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.

Posts: 20570
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.
Do not set lab on fire. Or this tiny ad:
global solutions you can do at home or in your backyard
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!