This week's book giveaway is in the XML and Related Technologies forum.
We're giving away four copies of Java XML & JSON and have Jeff Friesen on-line!
See this thread for details.
Win a copy of Java XML & JSON this week in the XML and Related Technologies 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 ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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: 20307
110
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.
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!