Ystem.out and System.err are printed to catalina.out. Catalina.out will not rotate. Generally after the deployment of Tomcat, run for a long time, the Catalina.out file will be more and more large, the stability of the system has caused a certain impact.
1. This section of the log information can be masked by modifying the Conf/logging.properties log profile.
[[email protected] conf]# Pwd/usr/local/tomcat/conf[[email protected] conf]# CP logging.properties Logging.propertiesbak[[email protected] conf]# vim logging.properties 1catalina.org.apache.juli.filehandler.level = FINE 1catalina.org.apache.juli.filehandler.directory = ${catalina.base}/logs 27 1catalina.org.apache.juli.filehandler.prefix = Catalina.
Setting the level to warning can reduce the output of the log a lot, and of course it can be set to off and disabled directly.
The general log levels are:
SEVERE (highest value) > WARNING > INFO > CONFIG > FINE > Finer > FINEST (lowest value)
2. Use the Cronolog tool to slice Tomcat's catalina.out log files
Download, install Cronolog
[[EMAIL PROTECTED] SRC]# RPM -QA |GREP CRONOLOG[[EMAIL PROTECTED] SRC] # tar zxvf cronolog-1.6.2.tar.gz [[email protected] src]# cd cronolog-1.6.2[[email protected] cronolog-1.6.2]# mkdir /usr/local/cronolog[[email Protected] cronolog-1.6.2]# ./configure --prefix=/usr/local/cronolog/......checking for  WORKING MAKEINFO... MISSINGCHECKING FOR GCC... NOCHECKING FOR CC ... noconfigure: error: no acceptable cc found in $PATH [[email Protected] cronolog-1.6.2]# yum -y install gcc gcc-c++[[email protected] cronolog-1.6.2]# ./configure [[email protected] cronolog-1.6.2]# make && make install[[email protected] cronolog-1.6.2]# which cronolog/usr/ Local/sbin/cronolog[[email protected] cronolog-1.6.2]#
With which cronolog you can find the path to the installation, which will be used when modifying catalina.sh.
Modify catalina.sh 183 lines to 184 lines, comment out 355 lines, 368, 369 lines replaced by 370, 371 lines, 379, 380 lines replaced by 381, 382 lines
[[email protected] cronolog-1.6.2]# cp /usr/local/tomcat/bin/catalina.sh /usr/local/ tomcat/bin/catalina.shbak[[email protected] cronolog-1.6.2]# vim /usr/local/tomcat/bin/ catalina.sh182 if [ -z "$CATALINA _out" ] ; then183 # catalina_out= "$CATALINA _base"/logs/catalina.out184 catalina_out= "$CATALINA _base"/logs/ Catalina.%y-%m-%d.out185 fi ... 355 # touch "$CATALINA _out" ... 368 # org.apache.catalina.startup.bootstrap "[email Protected] " start 369 org.apache.catalina.startup.bootstrap "[email protected]" start 2>&1 370 # >> "$CATALINA _out" 2>&1 &371 | / usr/local/sbin/cronolog "$CATALINA _out" > > /dev/null & 363 -djava.security.manager 364 -djava.security.policy== "$CATALINA _base"/conf/catalina.policy 365 -dcatalina.base= "$CATALINA _base" 366 - Dcatalina.home= "$CATALINA _home" 367 -djava.io.tmpdir= "$CATALINA _ TMPDIR " 368 # org.apache.catalina.startup.Bootstrap " [email Protected] " start 369 # >> " $CATALINA _out " 2 >&1 &370 org.apache.catalina.startup.Bootstrap "[Email protected] " start 2>&1 \ 371 | /usr/ local/sbin/cronolog "$CATALINA _out" >> /dev/null &372 373 else374 "$_runjava" "$LOGGING _config" $LOGGING _manager $ java_opts $CATALINA _opts 375 -djava.endorsed.dirs= "$JAVA _ Endorsed_dirs " -classpath " $CLASSPATH " 376 - dcatalina.base= "$CATALINA _base" 377 -dcatalina.home= "$CATALINA _ HOME " 378 -djava.io.tmpdir=" $CATALINA _tmpdir " 379 # org.apache.catalina.startup.Bootstrap "[email protected]" start 380 # >> "$CATALINA _out" 2>&1 &381 org.apache.catalina.startup.Bootstrap "[email protected]" start 2>&1 \ 382 | /usr/local/sbin/ cronolog "$CATALINA _out" >> /dev/null &383 384 fi[[email protected] cronolog-1.6.2 ]# service tomcat stop[[email protected] cronolog-1.6.2]# service tomcat start
So the catalina.%y-%m-%d.out files are automatically generated every day in/usr/local/tomcat/logs, and the next thing we do is to periodically clean up these outdated files, and we can implement the
by crontab.
[Email protected] logs]# Crontab-eno crontab for root-using an empty onecrontab:installing new Crontab[[email Protect Ed] logs]# CRONTAB-L30 5 * * 6/bin/find/usr/local/tomcat/logs/-mtime +7-type f-name "Catalina.*.out"-exec/bin/rm- f {} \; [Email protected] logs]# cat/var/spool/cron/root 5 * 6/bin/find/usr/local/tomcat/logs/-mtime +7-type f-name "c Atalina.*.out "-exec/bin/rm-f {} \; [Email protected] logs]#
Fill: Nginx Log logs are divided into Access.log and Error.log, where Access.log records which users, which pages and user browser, IP, and other access information, Error.log is the record server error log.
Error.log Log in the following form:
201.158.69.116 - - [03/jan/2013:21:17:20 -0600] fwf[-] tip[-] 127.0.0.1:9000 0.007 0.007 mx pythontab.com get / html/test.html http/1.1 "$" 2426 "http://a.com" "es-es,es;q=0.8" "mozilla/5.0 (windows nt 6.1) AppleWebKit/537.11 (Khtml, like gecko) chrome/ 23.0.1271.97 safari/537.11 "187.171.69.177 - - [03/jan/2013:21:17:20 -0600] fwf[- ] tip[-] 127.0.0.1:9000 0.006 0.006 mx pythontab.com get /html/ test2.html http/1.1 "$" 2426 "http://a.com" "es-es,es;q=0.8" "mozilla/5.0 (windows nt 6.1) AppleWebKit/537.11 (Khtml, like gecko) chrome/ 23.0.1271.97 safari/537.11 "
From the above we can see a few pieces of information:
1. Client (user) IP address. such as: 201.158.69.116 in the above example
2. Access time. Example: [03/jan/2013:21:17:20-0600] in the example above
3. Access the port. such as: 127.0.0.1:9000 in the above example
4. Response time. such as: 0.007 in the previous example
5. Request time. such as: 0.007 in the previous example
6. User Location Code (country code). Example: MX (Mexico) in the example above
7. Host of the requested URL address (destination URL address). such as: Pythontab.com in the above example
8. Request method (get or post, etc.). Example: The GET in the previous example
9. Request the URL address (remove the host section). such as:/html/test.html in the above example
10. Request Status (status code, 200 indicates success, 404 means the page does not exist, 301 means permanent redirect, etc.), the status code can be found on the Internet related articles, no longer repeat. such as: "200" in the above example
11. Request page size, default to B (Byte). such as: 2426 in the previous example
12. Source page, that is, from which page to go to this page, the professional name is called "Referer". such as: "Http://a.com" in the above example
13. User Browser language. such as: "es-es,es;q=0.8" in the above example
14. User browser Other information, browser version, browser type, etc. Example: "mozilla/5.0 (Windows NT 6.1) applewebkit/537.11 (khtml, like Gecko) chrome/23.0.1271.97 safari/537.11" in the example above
Access.log Log format is not immutable and can be customized. Found in nginx nginx.conf configuration file: Log_format Here is the format of the log
log_format main ' $remote _addr - $remote _user [$time _local] ' ' fwf[$http _x_forwarded_for] tip[$http _true_client_ip] ' ' $upstream _addr $ upstream_response_time $request _time ' ' $geoip _country_code ' ' $http _host $request ' ' $status ' $body _bytes_sent "$http _referer" '     &Nbsp; ' "$http _ Accept_language " " $http _user_agent " ";
112.97.37.90--[14/sep/2013:14:37:39 +0800] "get/http/1.1" 301 5 "-" "mozilla/5.0 (Linux; U Android 2.3.6; ZH-CN; Lenovo A326 build/grk39f) applewebkit/533.1 (khtml, like Gecko) version/4.0 Mobile safari/533.1 micromessenger/4.5.1.259 " -
Linux regularly cuts tomcat logs and deletes log records before a specified number of days