tomcat access日志
每次看access log都会记不住pattern里的各个标识代表的什么意思,记录下,备忘!
tomcat的access log是由实现了org.apache.catalina.AccessLog接口的Valve完成的,(Valve是tomcat配置文件server.xml中的一个标签元素)
下面来简单介绍下tomcat的Access Log Valve
简介
标签属性
访问日志Valve支持一下属性配置
| 属性 | 原文描述 | 瞎比翻译 |
| className | Java class name of the implementation to use. This MUST be set to org.apache.catalina.valves.AccessLogValve to use the default access log valve. | 指定需要的 |
| directory | Absolute or relative pathname of a directory in which log files created by this valve will be placed. If a relative path is specified, it is interpreted as relative to $CATALINA_BASE. If no directory attribute is specified, the default value is "logs" (relative to $CATALINA_BASE). | 日志文件存放路径( $CATALINA_BASE的相对路径) |
| prefix | The prefix added to the start of each log file's name. If not specified, the default value is "access_log.". | 日志文件统一前缀 |
| suffix | The suffix added to the end of each log file's name. If not specified, the default value is "" (a zero-length string), meaning that no suffix will be added. | 日志文件统一后缀 |
| fileDateFormat | Allows a customized timestamp in the access log file name. The file is rotated whenever the formatted timestamp changes. The default value is yyyy-MM-dd. If you wish to rotate every hour, then set this value to yyyy-MM-dd.HH. The date format will always be localized using the locale en_US. |
日志文件名上的时间格式 |
| rotatable | Flag to determine if log rotation should occur. If set to false, then this file is never rotated and fileDateFormat is ignored. Default value: true |
是否分隔日志文件 |
| renameOnRotate | By default for a rotatable log the active access log file name will contain the current timestamp in fileDateFormat. During rotation the file is closed and a new file with the next timestamp in the name is created and used. When setting renameOnRotate to true, the timestamp is no longer part of the active log file name. Only during rotation the file is closed and then renamed to include the timestamp. This is similar to the behavior of most log frameworks when doing time based rotation. Default value: false |
当前写入的日志文件不带时间标识 |
| pattern | A formatting layout identifying the various information fields from the request and response to be logged, or the word common or combined to select a standard format. See below for more information on configuring this attribute. |
|
| encoding | Character set used to write the log file. An empty string means to use the system default character set. Default value: use the system default character set. | 编码 |
| locale | The locale used to format timestamps in the access log lines. Any timestamps configured using an explicit SimpleDateFormat pattern (%{xxx}t) are formatted in this locale. By default the default locale of the Java process is used. Switching the locale after the AccessLogValve is initialized is not supported. Any timestamps using the common log format (CLF) are always formatted in the locale en_US. |
|
| requestAttributesEnabled | Set to true to check for the existence of request attributes (typically set by the RemoteIpValve and similar) that should be used to override the values returned by the request for remote address, remote host, server port and protocol. If the attributes are not set, or this attribute is set to false then the values from the request will be used. If not set, the default value of false will be used. |
|
| conditionIf | Turns on conditional logging. If set, requests will be logged only if ServletRequest.getAttribute() is not null. For example, if this value is set to important, then a particular request will only be logged if ServletRequest.getAttribute("important") != null. The use of Filters is an easy way to set/unset the attribute in the ServletRequest on many different requests. |
|
| conditionUnless | Turns on conditional logging. If set, requests will be logged only if ServletRequest.getAttribute() is null. For example, if this value is set to junk, then a particular request will only be logged if ServletRequest.getAttribute("junk") == null. The use of Filters is an easy way to set/unset the attribute in the ServletRequest on many different requests. |
|
| condition | The same as conditionUnless. This attribute is provided for backwards compatibility. |
|
| buffered | Flag to determine if logging will be buffered. If set to false, then access logging will be written after each request. Default value: true |
|
| resolveHosts |
This attribute is no longer supported. Use the connector attribute If you have |
pattern属性
当前请求的request和response中的属性输出
| 标签 | 原文解析 | 瞎比翻译 |
| %a | Remote IP address | 远程ip地址 |
| %A | Local IP address | 本地ip地址 |
| %b | Bytes sent, excluding HTTP headers, or '-' if zero | 不包含http头部的发送字节数 |
| %B | Bytes sent, excluding HTTP headers | 包含http头部的发送字节数 |
| %h | Remote host name (or IP address if enableLookups for the connector is false) |
远程主机名(如果标签enableLookups=false,就是ip地址了) |
| %H | Request protocol | 使用的协议 |
| %l | Remote logical username from identd (always returns '-') | 总是返回‘-’,有毛用啊 |
| %m | Request method (GET, POST, etc.) | 请求方法 |
| %p | Local port on which this request was received. See also %{xxx}p below. |
接受这次请求的本地端口号 |
| %q | Query string (prepended with a '?' if it exists) | url后面的查询字符串 |
| %r | First line of the request (method and request URI) | http请求的第一行? |
| %s | HTTP status code of the response | http响应的状态码 |
| %S | User session ID | 会话id |
| %t | Date and time, in Common Log Format | 请求访问时间 |
| %u | Remote user that was authenticated (if any), else '-' | ? |
| %U | Requested URL path | 请求的路径 |
| %v | Local server name | 本地服务名 |
| %D | Time taken to process the request, in millis | 毫秒单位的请求耗时 |
| %T | Time taken to process the request, in seconds | 秒单位的请求耗时 |
| %F | Time taken to commit the response, in millis | 毫秒单位的提交响应结果的耗时 |
| %I | Current request thread name (can compare later with stacktraces) | 当前请求的线程名称 |
请求头部、响应头部、cookies、session及特殊时间戳的信息输出
| 标识 | 原文解析 | 瞎比翻译 |
%{xxx}i |
write value of incoming header with name xxx |
请求头部属性 |
%{xxx}o |
write value of outgoing header with name xxx |
响应头部属性 |
%{xxx}c |
write value of cookie with name xxx |
cookie信息 |
%{xxx}r |
write value of ServletRequest attribute with name xxx |
request?和上面的一样功能? |
%{xxx}s |
write value of HttpSession attribute with name xxx |
会话信息 |
%{xxx}p |
write local (server) port (xxx==local) or remote (client) port (xxx=remote) |
端口 |
|
write timestamp at the end of the request formatted using the enhanced SimpleDateFormat pattern xxx |
时间戳 |
参考
http://tomcat.apache.org/tomcat-7.0-doc/config/valve.html
tomcat access日志的更多相关文章
- 完整的多项匹配tomcat access日志的正则
<pre name="code" class="html"><pre name="code" class="ht ...
- Servlet、Tomcat访问(access)日志配置、记录Post请求参数
一.运行环境: Maven:3.5.2(点击下载) ,下载页 Tomcat:8.5.29(点击下载) ,下载页 JDK:jdk1.7.0_80(点击下载) ,下载页 MavenDependency: ...
- Tomcat访问(access)日志配置
在tomcat的access中打印出请求的情况可以帮助我们分析问题,通常比较关注的有访问IP.线程号.访问url.返回状态码.访问时间.持续时间. 最近在跟一个图片请求超时的问题,需要在项目的acce ...
- spring boot打开tomcat的access日志
spring boot虽说内置了tomcat,但打出来的是jar包而非war包,更没有access日志,那么如何打开access日志呢?只需在application.properties中加入相关配置 ...
- Tomcat访问日志详细配置
在server.xml里的<host>标签下加上 <Valve className="org.apache.catalina.valves.AccessLogValve&q ...
- tomcat详细日志配置
在server.xml里的<host>标签下加上<Valve className="org.apache.catalina.valves.AccessLogValve&qu ...
- Tomcat access log配置
在tomcat的access中打印出请求的情况可以帮助我们分析问题,通常比较关注的有访问IP.线程号.访问url.返回状态码.访问时间.持续时间. 在Spring boot中使用了内嵌的tomcat, ...
- spring boot(13)-logback和access日志
logback logback出自log4j的作者,性能和功能相比log4j作出了一些改进,而配置方法和log4j类似,是spring boot的默认日志组件.在application.propert ...
- Tomcat中日志组件
Tomcat日志组件 AccessLog接口 public interface AccessLog { public void log(Request request, Response respon ...
随机推荐
- 为什么DW的可视化下看到的效果与浏览器的效果有所区别?
可视区不是调用外面浏览器,Dreamweav 可视化区是为用户编辑而设计. 支持最基本的 HTML 与 CSS ,对 CSS 而言,我写入样式时如果你使用最基本的样式时它显示与你浏览器中看的效果相差不 ...
- 关于Python缩进,我们该了解哪些?
Python是一门独特的语言,它的代码块是通过缩进(Indentation)来标记的(大部分语言都是使用花括号作为代码块的标记),具有相同缩进的多行代码属于同一个代码块.如果代码莫名其妙的乱缩进,Py ...
- 学习JDK1.8集合源码之--ArrayList
参考文档: https://cloud.tencent.com/developer/article/1145014 https://segmentfault.com/a/119000001857894 ...
- 计算机网络3.2&3.3(第二节介质&第三节多路复用)
有限的传播介质 双绞线 双绞线电缆 双绞线总结 2 同轴电缆 粗细电缆的传输距离 现在基本都用双绞线和光线 同轴电缆用于居民小区和家庭使用 3 光纤 光纤中以光信号的形式进行传播 正如我们现在看到这样 ...
- 配置了两天python【python可以的】
首先是看cs231n 发现代码的版本是py2 而我只装了 py3(anaconda3) 怎么办呢 于是想办法装了 anaconda2 并与之共存 ,调用的时候用 activate py2调用 http ...
- iOS自动化打包上传的踩坑记
http://www.cocoachina.com/ios/20160624/16811.html 很久以前就看了很多关于iOS自动打包ipa的文章, 看着感觉很简单, 但是因为一直没有AppleDe ...
- Xdebug步骤
谷歌浏览器安装xdebug cd /etc/php/7.2/fpm/conf.d 重启sudo service php7.1-fpm restart (注意 php版本) 重启编辑器
- 如何使用Data Lake Analytics创建分区表
前言 Data Lake Analytics(后文简称DLA)提供了无服务化的大数据分析服务,帮助用户通过标准的SQL语句直接对存储在OSS.TableStore上的数据进行查询分析. 在关系型数据库 ...
- HDU 4217
点击打开题目链接 题型就是数据结构.给一个数组,然后又k次操作,每次操作给定一个数ki, 从数组中删除第ki小的数,要求的是k次操作之后被删除的所有的数字的和. 简单的思路就是,用1标记该数没有被删除 ...
- 【Leetcode链表】奇偶链表(328)
题目 给定一个单链表,把所有的奇数节点和偶数节点分别排在一起.请注意,这里的奇数节点和偶数节点指的是节点编号的奇偶性,而不是节点的值的奇偶性. 请尝试使用原地算法完成.你的算法的空间复杂度应为 O(1 ...