设置日志显示信息格式,默认情况下,Tomcat的访问日志是不记录的。需要在serve.xml中修改配置,去掉注释。
    <!--
       
<Valve
className="org.apache.catalina.valves.AccessLogValve"
                
directory="logs"  prefix="localhost_access_log."
suffix=".txt"
                
pattern="common" resolveHosts="false"/>
       
-->
将注释去掉即可。
    
如果要调整日志记录的字段,需要修改pattern属性值,common是默认的属性,其值为: %h %l %u %t %r %s
%b
    
各符号表示为(下面描述摘自Tomcat官方文档):
    *
%a - Remote IP address
    * %A - Local
IP address
    * %b - Bytes
sent, excluding HTTP headers, or '-' if zero
    * %B - Bytes
sent, excluding HTTP headers
    * %h -
Remote host name (or IP address if resolveHosts is false)
    * %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
    * %q - Query
string (prepended with a '?' if it exists)
    * %r - First
line of the request (method and request URI)
    * %s - HTTP
status code of the response
    * %S - User
session 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
    
There is also support to write information from the cookie,
incoming header,
the Session or something else in the ServletRequest. It is
modeled after the apache syntax:

*
%{xxx}i for incoming
headers
    *
%{xxx}c for a specific
cookie
    *
%{xxx}r xxx is an attribute in
the ServletRequest
    *
%{xxx}s xxx is an attribute in
the HttpSession

   
通常情况下,为便于分析网站瓶颈,将pattern=“%h %l %u %t "%r" %s %b
%D”,其中D代表处理该请求所消耗的毫秒数,
如此可以方便找到问题,提高系统性能。
 
http://blog.sina.com.cn/s/blog_6c9a9a870100m2ak.html
http://blog.chinaunix.net/uid-20691565-id-3938220.html
 

Tomcat日志格式自定义的更多相关文章

  1. ELK 收集 Tomcat日志以及修改Tomcat日志格式

    ELK 收集 Tomcat日志以及修改Tomcat日志格式 Tomcat日志 想要收集tomcat 日志 首先我们要对tomcat的日志有足够的了解 tomca日志分类 简单的说tomcat logs ...

  2. tomcat日志格式中的含义

    %a - 远程IP地址 %A - 本地IP地址 %b - 发送的字节数,不包括HTTP头,或“ - ”如果没有发送字节 %B - 发送的字节数,不包括HTTP头 %h - 远程主机名 %H - 请求协 ...

  3. docker中tomcat日志输出自定义

    一,默认tomcat日志配置文件 /data/tomcat/conf/logging.properties 1,修改tomcat/conf下的logging.properties [root@harb ...

  4. ELK对Tomcat日志双管齐下-告警触发/Kibana日志展示

    今天我们来聊一聊Tomcat,相信大家并不陌生,tomcat是一个免费开源的web应用服务器,属于轻量级的应用程序,在小型生产环境和并发不是很高的场景下被普遍使用,同时也是开发测试JSP程序的首选.也 ...

  5. 在CentOS 6上使用 AWStats 分析 httpd 和 Tomcat 日志

    准备工作: Awstats 是由perl语言编写的,所以要首先准备好awstats的运行环境.# yum install –y perl*   Apache 一.首先,要安装apache服务器,并且启 ...

  6. 给Nginx配置日志格式和调整日期格式

    效果对比 官方默认日志格式 # 官方默认日志格式 log_format main '$server_name $remote_addr - $remote_user [$time_local] &qu ...

  7. 【教程】Tomcat 的catalina.out 日志按照自定义日期格式进行切割

    本文简单介绍在使用cronolog对tomcat的日志进行自定义日期格式的切割,方便日志的整理和遇到问题日志的排查! 安装cronolog 安装cronolog的方法网上有很多,这里也简单的介绍一下. ...

  8. ELK 之三:Kibana 使用与Tomcat、Nginx 日志格式处理

    一:kibana安装: kibana主要是搜索elasticsearch的数据,并进行数据可视化的展现,新版使用nodejs. 1.下载地址: https://www.elastic.co/downl ...

  9. tomcat的catalina.out日志按自定义时间日式进行分割

    使用cronolog对tomcat的日志进行自定义日期格式的切割,方便日志的整理和遇到问题日志的排查! 1.安装cronolog工具1.1 下载 cronolog 地址:网上很多下载地址这里就不在累赘 ...

随机推荐

  1. List常用子类的特点

    ArrayList:    底层数据结构是数组,查询快,增删慢   线程不安全, 效率较高 Vector   底层数据结构是数组,查询快,增删慢   线程安全, 效率较低 LinkedList   底 ...

  2. redis-py说明文件(转)

    转自:http://blog.sina.com.cn/s/blog_6262a50e0101574h.html 原文:https://github.com/andymccurdy/redis-py r ...

  3. Short Circuit Protection Circuit

    http://www.daycounter.com/Circuits/Short-Circuit-Protection/Short-Circuit-Protection.phtml Short cir ...

  4. MFC中添加ToolTip提示框

    PART 1 MFC 对话框中的 Buttton添加提示 例如我们想在一个对话框中的一个button控件添加tooltip,实现的方法如下: 1. 在该对话框的类中添加一个CToolTipCtrl类型 ...

  5. 配置quartz数据源的三种方式

    如果是使用了JDBC JobStore或JobStoreCMT获得持久的Job时,就要配置相关的数据源了. 方式一:使用quartz.properties文件,这时只需要在property文件中增加如 ...

  6. 兼容的动态加载JS【原】

    兼容的动态加载JS 屌丝就是悲剧,五一还得宅家里写程序专研技术. 说起动态加载JS,搞web的肯定不陌生,著名的YUI库就有强大的模块化的动态加载JS机制.在代码量不断庞大的今天,动态加载JS作用还是 ...

  7. 基于libhid/libusb进行开发

    操作环境:ubuntu,基于libhid/libusb进行开发   libusb介绍: libusb 设计了一系列的外部API 为应用程序所调用,通过这些API应用程序可以操作硬件,从libusb的源 ...

  8. 基尼系数(Gini coefficient),洛伦茨系数

    20世纪初意大利经济学家基尼,于1922年提出的定量测定收入分配差异程度的指标.它是根据洛伦茨曲线找出了判断分配平等程度的指标(如下图). 设实际收入分配曲线和收入分配绝对平等曲线之间的面积为A,实际 ...

  9. Android中intent如何传递自定义数据类型

    转载自:http://www.cnblogs.com/GoAhead/archive/2012/07/16/2593868.html 大家好,好久不见,今天要给大家讲一下Android中Intent中 ...

  10. Android之属性动画(二)

    上一篇文章(链接:http://www.cnblogs.com/jerehedu/p/4458928.html  ),我们对属性动画有了简单的认识,并实际动手使用ObjectAnimator.Anim ...