博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
tomcat 日志详解
阅读量:4842 次
发布时间:2019-06-11

本文共 12269 字,大约阅读时间需要 40 分钟。

1 tomcat  日志详解

1.1  tomcat 日志配置文件

  tomcat 对应日志的配置文件:tomcat目录下的/conf/logging.properties。

  tomcat 的日志等级有:日志输出级别:SEVERE (最高级别) > WARNING > INFO > CONFIG > FINE > FINER(精心) > FINEST (所有内容,最低级别)

  tomcat  有五类日志 :catalina、localhost、manager、admin、host-manager

  /conf/logging.properties 配置文件:

1 #可配置项(5类日志):catalina、localhost、manager、admin、host-manager 2 handlers = 1catalina.org.apache.juli.FileHandler, 2localhost.org.apache.juli.FileHandler, 3 3manager.org.apache.juli.FileHandler, 4host-manager.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler 4  5 #日志输出为输出到文件和输出到控制台 6 .handlers = 1catalina.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler 7  8 #日志输出级别:SEVERE (最高级别) > WARNING > INFO > CONFIG > FINE > FINER(精心) > FINEST (所有内容,最低级别) 9 #配置文件使catalina日志输出级别为FINE10 1catalina.org.apache.juli.FileHandler.level = FINE11 #catalina文件输出位置12 1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs13 #catalina日志前缀为catalina14 1catalina.org.apache.juli.FileHandler.prefix = catalina.15 16 #配置文件使localhost日志输出级别为FINE17 2localhost.org.apache.juli.FileHandler.level = FINE18 #localhost文件输出位置19 2localhost.org.apache.juli.FileHandler.directory = ${catalina.base}/logs20 #localhost日志前缀为localhost21 2localhost.org.apache.juli.FileHandler.prefix = localhost.22 23 #配置文件使manager日志输出级别为FINE24 3manager.org.apache.juli.FileHandler.level = FINE25 #manager文件输出位置26 3manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs27 #manager日志前缀为manager28 3manager.org.apache.juli.FileHandler.prefix = manager.29 30 #配置文件使host-manager日志输出级别为FINE31 4host-manager.org.apache.juli.FileHandler.level = FINE32 #host-manager文件输出位置33 4host-manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs34 #host-manager日志前缀为host-manager35 4host-manager.org.apache.juli.FileHandler.prefix = host-manager.36 37 #配置文件使控制台日志输出级别为FINE38 java.util.logging.ConsoleHandler.level = FINE39 #控制台日志输出格式40 java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter41 42 #localhost日志文件输出级别为INFO43 org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO44 #localhost日志文件输出处理类2localhost.org.apache.juli.FileHandler45 org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.FileHandler46 47 #manager日志文件输出级别为INFO48 org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO49 #manager日志文件输出处理类3manager.org.apache.juli.FileHandler50 org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = 3manager.org.apache.juli.FileHandler51 52 #host-manager日志文件输出级别为INFO53 org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = INFO54 #host-manager日志文件输出处理类4host-manager.org.apache.juli.FileHandler55 org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = 4host-manager.org.apache.juli.FileHandler

1.2  tomcat 日志文件详解

 tomcat  有五类日志 :catalina、localhost、manager、admin、host-manager

 1.2.1 catalina.out :

catalina.out即标准输出和标准出错,所有输出到这两个位置的都会进入catalina.out,这里包含tomcat运行自己输出的日志以及应用里向console输出的日志。默认这个日志文件是不会进行自动切割的,我们需要借助其他工具进行切割(注意:catalina.out文件如果过大会影响)

#截取部分日志19-Sep-2018 09:53:28.358 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:        Apache Tomcat/8.0.5319-Sep-2018 09:53:28.361 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Jun 29 2018 14:42:45 UTC19-Sep-2018 09:53:28.361 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:         8.0.53.019-Sep-2018 09:53:28.361 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Linux19-Sep-2018 09:53:28.361 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            3.10.0-862.el7.x86_6419-Sep-2018 09:53:28.361 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd6419-Sep-2018 09:53:28.361 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             /usr/java/jdk1.8.0_131/jre19-Sep-2018 09:53:28.361 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           1.8.0_131-b1119-Sep-2018 09:53:28.361 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation19-Sep-2018 09:53:28.361 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         /opt/tomcat19-Sep-2018 09:53:28.361 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         /opt/tomcat19-Sep-2018 09:53:28.361 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/opt/tomcat/conf/logging.properties19-Sep-2018 09:53:28.362 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager19-Sep-2018 09:53:28.362 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=204819-Sep-2018 09:53:28.362 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources19-Sep-2018 09:53:28.362 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=19-Sep-2018 09:53:28.362 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/opt/tomcat19-Sep-2018 09:53:28.362 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/opt/tomcat19-Sep-2018 09:53:28.362 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/opt/tomcat/temp19-Sep-2018 09:53:28.362 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib19-Sep-2018 09:53:28.676 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]19-Sep-2018 09:53:28.716 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read19-Sep-2018 09:53:28.731 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]19-Sep-2018 09:53:28.732 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read19-Sep-2018 09:53:28.746 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 1083 ms19-Sep-2018 09:53:28.794 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina19-Sep-2018 09:53:28.794 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.5319-Sep-2018 09:53:28.829 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /opt/tomcat/webapps/ROOT19-Sep-2018 09:53:29.524 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /opt/tomcat/webapps/ROOT has finished in 694 ms19-Sep-2018 09:53:29.524 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /opt/tomcat/webapps/docs19-Sep-2018 09:53:29.552 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /opt/tomcat/webapps/docs has finished in 28 ms19-Sep-2018 09:53:29.552 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /opt/tomcat/webapps/examples19-Sep-2018 09:53:29.987 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /opt/tomcat/webapps/examples has finished in 434 ms19-Sep-2018 09:53:29.987 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /opt/tomcat/webapps/host-manager19-Sep-2018 09:53:30.033 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /opt/tomcat/webapps/host-manager has finished in 46 ms19-Sep-2018 09:53:30.034 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /opt/tomcat/webapps/manager19-Sep-2018 09:53:30.064 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /opt/tomcat/webapps/manager has finished in 29 ms19-Sep-2018 09:53:30.082 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]19-Sep-2018 09:53:30.099 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]19-Sep-2018 09:53:30.106 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 1360 ms2018-09-19 16:52:10 [] [] [INFO]-[Thread: DefaultQuartzScheduler_Worker-7] 开始检查系统

    1.2.2 catalina.YYYY-MM-DD.log

 catalina.{yyyy-MM-dd}.log是tomcat自己运行的一些日志,这些日志还会输出到catalina.out,但是应用向console输出的日志不会输出到catalina.{yyyy-MM-dd}.log,它是tomcat的启动和暂停时的运行日志,注意,它和catalina.out是里面的内容是不一样的。

 
View Code

 1.2.3 localhost.YYYY-MM-DD.log

 localhost.{yyyy-MM-dd}.log主要是应用初始化(listener, filter, servlet)未处理的异常最后被tomcat捕获而输出的日志,它也是包含tomcat的启动和暂停时的运行日志,但它没有catalina.2018-09-19.log 日志全。它只是记录了部分日志。

 
View Code

 1.2.4 localhost_access_log.YYYY-MM-DD.txt

 localhost_access_log.2018-09-19.txt:这个是访问tomcat的日志,请求时间和资源,状态码都有记录。

192.168.1.220 - - [19/Sep/2018:03:57:42 -0400] "GET / HTTP/1.1" 200 11286192.168.1.220 - - [19/Sep/2018:03:57:42 -0400] "GET /tomcat.css HTTP/1.1" 200 5581192.168.1.220 - - [19/Sep/2018:03:57:42 -0400] "GET /tomcat.png HTTP/1.1" 200 5103192.168.1.220 - - [19/Sep/2018:03:57:42 -0400] "GET /bg-button.png HTTP/1.1" 200 713192.168.1.220 - - [19/Sep/2018:03:57:42 -0400] "GET /bg-nav.png HTTP/1.1" 200 1401192.168.1.220 - - [19/Sep/2018:03:57:42 -0400] "GET /asf-logo-wide.svg HTTP/1.1" 200 27235192.168.1.220 - - [19/Sep/2018:03:57:42 -0400] "GET /bg-middle.png HTTP/1.1" 200 1918192.168.1.220 - - [19/Sep/2018:03:57:42 -0400] "GET /bg-upper.png HTTP/1.1" 200 3103192.168.1.220 - - [19/Sep/2018:03:58:14 -0400] "GET / HTTP/1.1" 200 11286192.168.1.220 - - [19/Sep/2018:03:58:14 -0400] "GET /favicon.ico HTTP/1.1" 200 21630192.168.1.220 - - [19/Sep/2018:03:58:16 -0400] "GET / HTTP/1.1" 200 11286192.168.1.220 - - [19/Sep/2018:03:58:16 -0400] "GET /favicon.ico HTTP/1.1" 200 21630192.168.1.220 - - [19/Sep/2018:03:58:21 -0400] "GET / HTTP/1.1" 200 11286192.168.1.220 - - [19/Sep/2018:03:58:21 -0400] "GET /favicon.ico HTTP/1.1" 200 21630192.168.1.220 - - [19/Sep/2018:03:58:28 -0400] "GET /docs/setup.html HTTP/1.1" 200 14470192.168.1.220 - - [19/Sep/2018:03:58:28 -0400] "GET /docs/images/docs-stylesheet.css HTTP/1.1" 200 5780192.168.1.220 - - [19/Sep/2018:03:58:28 -0400] "GET /docs/images/tomcat.png HTTP/1.1" 200 5103192.168.1.220 - - [19/Sep/2018:03:58:28 -0400] "GET /docs/images/asf-logo.svg HTTP/1.1" 200 20486192.168.1.220 - - [19/Sep/2018:03:58:28 -0400] "GET /docs/images/fonts/fonts.css HTTP/1.1" 200 1943192.168.1.220 - - [19/Sep/2018:03:58:29 -0400] "GET /docs/images/fonts/OpenSans400.woff HTTP/1.1" 200 21956192.168.1.220 - - [19/Sep/2018:03:58:29 -0400] "GET /docs/images/fonts/OpenSans700.woff HTTP/1.1" 200 22748192.168.1.220 - - [19/Sep/2018:03:58:29 -0400] "GET /docs/images/fonts/OpenSans600.woff HTTP/1.1" 200 22604

 1.2.5 host-manager.YYYY-MM-DD.log

    host-manager.2018-09-19.log:这个估计是放tomcat的自带的manager项目的日志信息的,未看到有什么重要的日志信息。

  1.2.6 manager.YYYY-MM-DD.log

   manager.2018-09-19.log  : 这个是tomcat manager项目专有的日志文件.

1.3 tomcat  日志文件切割

  tomcat  的  catalina.out  文件tomcat 是不会进行日志切割的,当这个文件大于2G  时,会影响tomcat的运行。那么我们需要对这个文件进行日志切割,切割的方法有很多种:

  第一种:

  通过系统自带的切割工具:logrotate来进行切割。

  第二种:

  使用logj4进行切割日志。

  第三种:

  使用用cronolog分割tomcat的catalina.out文件 

  以上三种方法见:https://www.cnblogs.com/happy-king/p/9193401.html

转载于:https://www.cnblogs.com/linus-tan/p/11307460.html

你可能感兴趣的文章
.NET基础架构方法—DataTableToExcel通用方法
查看>>
一篇很全面的freemarker教程
查看>>
linux常用命令(个人总结)
查看>>
city-picker插件使用-移动h5三级联动
查看>>
如何安装多操作系统
查看>>
Codeforces 1132G(dfs序+线段树)
查看>>
Hibernate
查看>>
十二、异常处理
查看>>
HashMap和HashTable的区别
查看>>
团队作业9————事后诸葛亮分析
查看>>
quartz.net 使用(一)-执行定时计划任务
查看>>
github上的版本和本地版本冲突的解决方法
查看>>
Centos7安装gitlab服务器
查看>>
Oracle事务
查看>>
King's Pilots
查看>>
在android中使用SharedPreferences进行数据存储
查看>>
Aspose.Cells API 中文版文档 下载
查看>>
异步编程的解决方案(执行代码的先后顺序:1.主任务,任务队列:2.微任务,3.宏任务)Promise/Generator/async/Fetch...
查看>>
软件工程概论作业四
查看>>
Android学习(十) SQLite 基于SQLiteOpenHelper的操作方式
查看>>