Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8316879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:27:27+00:00 2026-06-08T21:27:27+00:00

I am using tomcat 6x in a Linux system. It prints a localhost log

  • 0

I am using tomcat 6x in a Linux system. It prints a localhost log file like localhost.2011-06-07, localhost.2011-06-08 on a daily basis. I want to rotate the localhost when it reaches 1MB.

I can rotate log files in log4j for my web apps. But this localhost log file of tomcat, I couldn’t get it to rotate. Has any got a solution other than using logrotate?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T21:27:29+00:00Added an answer on June 8, 2026 at 9:27 pm

    Do you not want to use logrotate, or does your sys admin not allow you to?

    Given that restriction, I’m afraid (from what I have been able to learn from the documentation) that there is no automatic way to do what you want (rotate log files based on the size alone).

    If you merely want to stop Tomcat’s default behavior of creating a new log every day (which I find extremely annoying for a development environment or low-traffic site), you can certainly do this by changing the fileDateFormat property of the Access Log “Valve”, which on Ubuntu Server is defined in /etc/tomcat7/server.xml. It’s probably in a similar location for Tomcat 6.

    Since you mention a restrictive sys admin, I gather that this server is not under your control, so that path is irrelevant. If you do have the ability to modify Tomcat’s log configuration, hopefully you know where to find the appropriate file.

    In that .xml file, look for the Valve entity with className set to “org.apache.catalina.valves.AccessLogValve” in the section which configures the “Catalina” Engine for the appropriate host for your site (localhost in my case). Although the Tomcat 6 documentation doesn’t mention it, one can deduce that the default fileDateFormat is “yyyy-MM-dd”. Including the day in the log filename tells Tomcat (by implication) that you also want the log rotated every day. If you wanted it to be rotated, say, only once a month, just change the fileDateFormat to “yyyy-MM”.

    On my server, the default Logging Valve definition was this:

    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />
    

    To change this to monthly log rotation, I would just add the appropriate fileDateFormat attribute:

    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               fileDateFormat="yyyy-MM" prefix="localhost_access_log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />
    

    Since I am able (and willing) to use logrotate, I have turned off Tomcat’s built-in log rotation and date-based file naming completely, and simply use logrotate to rotate the logs whenever the log reaches 1MB.

    Edit To answer dgrant’s question, the changes were to /etc/tomcat7/server.xml, and the actual valve configuration I’m using is this:

    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
           pattern="combined" rotatable="false"
           prefix="access_log" />
    

    Note that the ‘combined’ pattern is equivalent (at least for Tomcat 7) to the explicit pattern definition in the original configuration. All this is well-covered in my original documentation link if you want to read more. Just look for the section on the rotatable attribute.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Tomcat 6.0, and I want to know how can I configure Tomcat's
I'm trying to launch cassandra on my server (Linux based and using tomcat) and
I'm having problems when sending emails with attachments through linux using Javamail on Tomcat
I'm using tomcat 6.0.32 in windows 7. Inside a very simple servlet, inside the
I'm using tomcat 6.0 and struts2. When I try to click on a link
i am using tomcat server and i have added a rhino engine to able
I am using Tomcat server for my java based Application . My question is
I am using Tomcat 6 and have some questions about Apache mod_jk as follows.
I am using Tomcat 6.0 and getting the same red underline saying Can not
I was using Tomcat with Eclipse nicely. Now I cannot start the server. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.