【CentOS 7Tomcat配置5】,Tomcat日誌#180121

hellopasswdweb


Tomcat日誌

  • ls /usr/local/tomcat/logs
  • 其中catalina開頭的日誌爲tomcat的綜合日誌,他記錄tomcat服務相關信息,也會記錄錯誤日誌
  • 其中catalina.日期.log和catalina.out內容相同,前者會天天生成一個新的日誌
  • host-manager和manager爲管理相關的日誌,其中host-manager爲虛擬主機的管理日誌
  • localhost和localhost_access爲虛擬主機相關日誌,其中帶access字樣的日誌爲訪問日誌,不帶access字樣的爲默認虛擬主機的錯誤日誌
  • 訪問日誌默認不會生成,須要server.xml中配置一下
[root@localhost ~]# ls /usr/local/tomcat/logs/
catalina.2018-01-17.log  host-manager.2018-01-17.log  localhost.2018-01-21.log             manager.2018-01-17.log
catalina.2018-01-21.log  host-manager.2018-01-21.log  localhost_access_log.2018-01-17.txt  manager.2018-01-21.log
catalina.out             localhost.2018-01-17.log     localhost_access_log.2018-01-21.txt
[root@localhost ~]# cd !$
cd /usr/local/tomcat/logs/

綜合日誌 catalina.outapache

[root@localhost logs]# tail catalina.out
21-Jan-2018 08:33:02.036 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-80"]
Jan 21, 2018 8:33:02 AM com.fzb.zrlog.plugin.server.impl.NioServer create
INFO: plugin listening on port -> 47381
Jan 21, 2018 8:33:02 AM com.fzb.zrlog.plugin.server.impl.NioServer create
INFO: load jar files
21-Jan-2018 08:33:02.160 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
21-Jan-2018 08:33:02.171 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 58666 ms
INFO 2018-01-21 08:33:02,737  - {"downloadUrl":"http://dl.zrlog.com/release/zrlog-1.8.0-d1f36bc-release.war","type":"正式版","version":"1.8.0","buildId":"d1f36bc","fileSize":7306860,"releaseDate":"2017-12-12 01:32:01+08:00"}
www.123.cn
INFO 2018-01-21 08:33:05,462  - ZrLog New update found new [1.8.0-d1f36bc]

catalina.日期.logtomcat

[root@localhost logs]# tail catalina.2018-01-21.log 
21-Jan-2018 08:33:01.982 INFO [www.123.cn-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/logs] has finished in [10] ms
21-Jan-2018 08:33:01.982 INFO [www.123.cn-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/temp]
21-Jan-2018 08:33:01.991 INFO [www.123.cn-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/temp] has finished in [9] ms
21-Jan-2018 08:33:01.991 INFO [www.123.cn-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps]
21-Jan-2018 08:33:02.000 INFO [www.123.cn-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps] has finished in [8] ms
21-Jan-2018 08:33:02.000 INFO [www.123.cn-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/work]
21-Jan-2018 08:33:02.009 INFO [www.123.cn-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/work] has finished in [9] ms
21-Jan-2018 08:33:02.036 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-80"]
21-Jan-2018 08:33:02.160 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
21-Jan-2018 08:33:02.171 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 58666 ms

管理相關的日誌 manager.20xx-xx-xx.logapp

[root@localhost logs]# tail manager.2018-01-21.log

host-manager.20xx-xx-xx.logwebapp

[root@localhost logs]# tail host-manager.2018-01-21.log

默認爲空ui

虛擬主機相關日誌 localhost.日期.log日誌

[root@localhost logs]# tail localhost.2018-01-21.log 
	... 26 more

21-Jan-2018 08:26:53.705 INFO [localhost-startStop-3] org.apache.catalina.core.ApplicationContext.log SessionListener: contextDestroyed()
21-Jan-2018 08:26:53.705 INFO [localhost-startStop-3] org.apache.catalina.core.ApplicationContext.log ContextListener: contextDestroyed()
21-Jan-2018 08:27:00.265 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized()
21-Jan-2018 08:27:00.266 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized()
21-Jan-2018 08:31:58.772 INFO [localhost-startStop-2] org.apache.catalina.core.ApplicationContext.log SessionListener: contextDestroyed()
21-Jan-2018 08:31:58.773 INFO [localhost-startStop-2] org.apache.catalina.core.ApplicationContext.log ContextListener: contextDestroyed()
21-Jan-2018 08:33:00.420 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized()
21-Jan-2018 08:33:00.420 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized()

localhost_access_log.日期.txtcode

[root@localhost logs]# tail localhost_access_log.2018-01-21.txt 
192.168.9.1 - - [21/Jan/2018:08:30:24 +0800] "GET / HTTP/1.1" 404 -
192.168.9.1 - - [21/Jan/2018:08:30:24 +0800] "GET /favicon.ico HTTP/1.1" 404 -
192.168.9.1 - - [21/Jan/2018:08:30:25 +0800] "GET / HTTP/1.1" 404 -
192.168.9.1 - - [21/Jan/2018:08:30:25 +0800] "GET /favicon.ico HTTP/1.1" 404 -
192.168.9.1 - - [21/Jan/2018:08:30:26 +0800] "GET /favicon.ico HTTP/1.1" 404 -
192.168.9.1 - - [21/Jan/2018:08:30:27 +0800] "GET / HTTP/1.1" 404 -
192.168.9.1 - - [21/Jan/2018:08:30:27 +0800] "GET /favicon.ico HTTP/1.1" 404 -
192.168.9.1 - - [21/Jan/2018:08:30:29 +0800] "GET / HTTP/1.1" 404 -
192.168.9.1 - - [21/Jan/2018:08:30:45 +0800] "GET / HTTP/1.1" 404 -
192.168.9.1 - - [21/Jan/2018:08:30:51 +0800] "GET / HTTP/1.1" 404 -
  • 具體方法是對應虛擬主機的<Host></Host>裏面加入下面的配置(假如域名爲123.cn): <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="123.cn_access" suffix=".log" pattern="%h %l %u %t &quot;%r&quot;%s %b" />
  • prefix定義訪問日誌的前綴,suffix定義日誌的後綴,pattern定義日誌格式。新增長的虛擬主機默認並不會生成相似默認主機的localhost.日期.log日誌,錯誤日誌會統一記錄到catalina.out中。 關於tomcat日誌,最須要關注catalina.out,當出現問題時,應該第一次時間去查看它。

修改於 180121server

相關文章
相關標籤/搜索