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
Situation
The log files can be found at /var/log/tomcat.
Resolution
<!-- 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 "%r" %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 "%r" %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 "%r" %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 "%r" %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
Additional Information
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: 05-Oct-2021
- Modified Date:16-May-2023
-
- SUSE Manager for Retail
- SUSE Manager Server
For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com