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

hellopasswd


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.out

[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.日期.log

[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.log

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

host-manager.20xx-xx-xx.log

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

默认为空

虚拟主机相关日志 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.日期.txt

[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,当出现问题时,应该第一次时间去查看它。

修改于 180121

转载于:https://my.oschina.net/hellopasswd/blog/1610196

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值