Cronolog separates Tomcat catalina. out logs
Tomcat logs are output in catalina. as time passes, the generated log files become larger and larger. The main reason is that some information printed during debugging occupies space, such as System. out and log. The catalina. out file of tomcat is constantly expanding, which makes the disk space edge of the system small and inconvenient to view. Therefore, cronolog is used to split logs by date (in this example, the logs are separated by days ).
# tar zxvf cronolog-1.6.2.tar.gz# cd cronolog-1.6.2# ./configure# make# make install
Check the directory where cronolog is installed (verify that the installation is successful)
# Which cronolog
Normally:
/Usr/local/sbin/cronolog
To split catalina. out of tomcat, you need to do the following:
Versions earlier than Tomcat 7:
(1) Comment out (#)
Touch "$ CATALINA_BASE"/logs/catalina. out
(2) modify the catalina. sh file in the tomcat bin directory.
Org. apache. catalina. startup. Bootstrap "$ @" start \
> "$ CATALINA_BASE"/logs/catalina. out 2> & 1 &
Is
Org. apache. catalina. startup. Bootstrap "$ @" start 2> & 1 \
|/Usr/local/sbin/cronolog "$ CATALINA_BASE"/logs/catalina. % Y-% m-% d. out>/dev/null &
- After that, restart Tomcat to view the logs in catalina. out.2015-09-13 format in the logs file.
- Versions later than Tomcat 7:
1 step 1Set
If [-z "$ CATALINA_OUT"]; then
CATALINA_OUT = "$ CATALINA_BASE"/logs/catalina. out
Fi
Change
If [-z "$ CATALINA_OUT"]; then
CATALINA_OUT = "$ CATALINA_BASE"/logs/catalina. % Y-% m-% d. outFi
2 Step 2
Set
Touch "$ CATALINA_OUT"
Change
# Touch "$ CATALINA_OUT"
Step 3
Set
Org. apache. catalina. startup. Bootstrap "$ @" start \
> "$ CATALINA_OUT" 2> & 1 &
Change
Org. apache. catalina. startup. Bootstrap "$ @" start 2> & 1 \
|/Usr/local/sbin/cronolog "$ CATALINA_OUT">/dev/null &
- Or perform the following steps to achieve the same effect (recommended ):
# Vi bin/catalina. sh
Find the following line
Org. apache. catalina. startup. Bootstrap "$ @" start \
> "$ CATALINA_OUT" 2> & 1 &
There are two rows like this. The first is tomcat startup with the "-security" parameter, and the second is the default tomcat startup mode, that is, the part below else, we only need to modify it here.
In addition, you need to comment out the "$ CATALINA_OUT" line of touch.
The complete modification is as follows: # touch "$ CATALINA_OUT" if ["$1" = "-security"]; then ........ elseeval "\" $ _ RUNJAVA \ "\" $ LOGGING_CONFIG \ "" $ LOGGING_MANAGER $ JAVA_OPTS $ CATALINA_OPTS \-Djava. endorsed. dirs = "\" $ JAVA_ENDORSED_DIRS \ ""-classpath "\" $ CLASSPATH \ "" \-Dcatalina. base = "\" $ CATALINA_BASE \ "" \-Dcatalina. home = "\" $ CATALINA_HOME \ ""-Djava. io. tmpdir = "\" $ CATALINA_TMPDIR \ "" \ org. apache. catalina. startup. bootstrap "$ @" start 2> & 1 \ |/usr/local/sbin/cronolog "$ CATALINA_BASE"/logs/catalina. % Y-% m-% d. out>/dev/null & fi
After that, restart Tomcat to view the logs in catalina. out.2015-09-13 format in the logs file.
For more Tomcat tutorials, see the following:
Install and configure the Tomcat environment in CentOS 6.6
Install JDK + Tomcat in RedHat Linux 5.5 and deploy Java Projects
Tomcat authoritative guide (second edition) (Chinese/English hd pdf + bookmarks)
Tomcat Security Configuration and Performance Optimization
How to Use Xshell to view Tomcat real-time logs with Chinese garbled characters in Linux
Install JDK and Tomcat in CentOS 64-bit and set the Tomcat Startup Procedure
Install Tomcat in CentOS 6.5
Tomcat details: click here
Tomcat: click here
This article permanently updates the link address: