SUSE Support

Here When You Need Us

How to limit Tomcat log sizes in SUSE Manager

This document (000020406) is provided subject to the disclaimer at the end of this document.

Environment

SUSE Manager 4.x Server

Situation

Tomcat access logs are not limited by default, and may grow continuously. Eventually, this could fill up the partition.

The log files can be found at /var/log/tomcat.

Resolution

In the "/etc/tomcat/server.xml" file, look for these lines near the end:
<!-- Access log processes all example.
     Documentation at: /docs/config/valve.html
     Note: The pattern used is equivalent to using pattern="common" -->
<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"/>
The line starting with "<Valve..." is the valve element that configures how Tomcat handles the localhost_access_log. Include a "maxDays" field just before the closing "/>" tag to set the maximum number of days a log is kept before being removed. For example:
<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" maxDays="7" />
In this case, we're limiting the access logs to 7 days. Adjust as needed for your environment.
The element may also include the field "rotatable". If this is set to false, it must be set to "true". For example:
<Valve rotatable="true" className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" maxDays="7" />

In order to adjust the configuration for the other logs in /var/log/tomcat, on the next line after the existing Valve element, add a new valve element with a prefix value that matches the log you are configuring. For example, to limit the catalina log, add an element identical to the one above but set prefix equal to "catalina". For example:
<Valve rotatable="true" className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t &quot;%r&quot; %s %b" prefix="catalina" maxDays="7"/>
You may also like to add an element for Tomcat's localhost, hostmanager, host-manager, and manager logs.

Restart the services to pick up the change:
# spacewalk-service restart

Cause

Tomcat access logs use a different log mechanism than the usual system logs. These are not picked up by the system logrotate daemon.
 

Additional Information

Please note that these logs may contain important diagnostic information. If there is any issue we can assist with, please preserve the logs covering the time of the incident, as these may be required for us to investigate.

Disclaimer

This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.

  • Document ID:000020406
  • Creation Date: 08-Nov-2021
  • Modified Date:16-May-2023
    • SUSE Manager for Retail
    • SUSE Manager Server

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.