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