Modify Tomcat's access log store path and filename _tomcat

Source: Internet
Author: User

The access Log in tomcat is stored by default in the logs directory. This directory will be bigger and larger, and if the traffic is large, the hard drive will soon be packed.


There are two ways to solve this problem:

Do not log access log: Comment out the <Valve> configuration items in Server.xml store the access log elsewhere, and then compress the archive periodically: Modify the Server.xml in <Valve> configuration items in the Directory parameter to another path in the large hard drive

In a running system, take a few more steps to stop Tomcat, remove the existing access log file from the Tomcat/logs, modify the configuration file, and then restart Tomcat. A specific example of modification is as follows:

Suppose the new storage path is/opt/logs/access_logs, and the filename prefix is modified to Xjj_access_log to avoid confusion with other tomcat logs: Cd/opt/logs mkdir access_logs vim/opt/app/ Tomcat-xjj/conf/server.xml modification: directory= "/opt/logs/access_logs" Modified: prefix= "Xjj_access_log" Stop tomcat:/opt/app/ Tomcat-xjj/bin/shutdown.sh cannot be stopped. Kill: Kill-9 <pid> cd/opt/app/tomcat-xjj/logs
Rename Localhost_access_log xjj_access_log *.txt (using suffix. txt to filter out all Access log files and batch renaming) MV *.txt/opt/logs/access_logs/Restart T omcat:/opt/app/tomcat-xjj/bin/startup.sh

Then, if necessary, write another script to periodically compress the files in the archive/opt/logs/access_logs (step slightly).


More about the configuration reference for Tomcat Access log: https://tomcat.apache.org/tomcat-8.0-doc/config/valve.html#Access_Logging

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.