`

tomcat access log配置

阅读更多

To monitor who is using your server, set up HTTP access logging in Tomcat. Every request that comes to Tomcat gets a

Setting up Logging

To setup access logging, edit the Tomcat server configuration file, ${tomcat_home}/conf/server.xml and uncomment the AccessLogValve :

        <Valve className="org.apache.catalina.valves.AccessLogValve"
                 directory="logs"  prefix="localhost_access_log." suffix=".txt"
                 pattern="common" resolveHosts="false"/>

By default the log files are created in the ${tomcat_home}/logs directory and roll over to a new file at midnight.

The log messages can be written in either of two standard web access log formats by setting the pattern attribute to common or combined . These appear to be the ones used by web log analyseres. Other log formats can be specified with the pattern attribute.

More information on the AccessLogValve and the pattern attribute can be found on the Tomcat Valve Configuration Reference .

Modifying the Log Format

We can extend the "common" and "combined" patterns by appending the response time for each request. To use this, set the

  • common : pattern="common"
  • common plus response time : pattern="%h %l %u %t &quot;%r&quot; %s %b %D"
  • combined : pattern="combined"
  • combined plus response time : pattern="%h %l %u %t &quot;%r&quot; %s %b &quot;%{Referer}i&quot; &quot;%{User-Agent}i&quot; %D"

 

Using FastCommonAccessLogValve(注意:tomcat6不包含此类)

The FastCommonAccessLogValve has better performance than the AccessLogValve . If you are running a production system, you might consider switching to the FastCommonAccessLogValve . The main restriction is that only the "common" and "combined" log formats can be used.

        <Valve className="org.apache.catalina.valves.FastCommonAccessLogValve"
                 directory="logs"  prefix="localhost_access_log." suffix=".txt"
                 pattern="common" resolveHosts="false"/>


The Logging Output

Here is a sample entry from the motherlode logs, using the combined plus response time pattern.

Example log entry:

82.93.133.81 - joe [01/Jul/2007:08:44:38 -0600] "GET /thredds/dodsC/fmrc/NCEP/GFS/Global_0p5deg/offset/NCEP-GFS-Global_0p5deg_Offset_0.0
hr.dds HTTP/1.1" 200 32707 "null" "IDV/NetcdfJava/HttpClient" 2999
Example Value Meaning
82.93.133.81 client IP address
- not used
joe authenticated username
[01/Jul/2007:08:44:38 -0600] request time
"GET ..." HTTP request verb and path
200 HTTP response code
32707 bytes transferred
"null" Referer
"IDV/NetcdfJava/HttpClient" client name
2999 response time in msecs

 

Using Web Log Analysers

We have used these two Web Log Analysers, but there are many others to choose from.

分享到:
评论
1 楼 rmn190 2011-04-01  
不错, 很管用。
多谢!

相关推荐

    tomcat访问(access)日志配置和记录Post请求参数

    一、配置与说明 tomcat访问日志格式配置,在config/server.xml里Host标签下加上 prefix=localhost_access_log. suffix=.txt pattern=%h&gt; 我们在日志文件中将看到如下文本: 10.217.14

    tomcat-access-log-js-parser:将 Tomcat 访问日志 [line] 解析为 JSON 字符串的 JavaScript 函数

    tomcat-access-log-js-parser Javascript 函数将 Tomcat 访问日志行解析为 JSON 字符串。 parseCommonFormat(line)和parseCommonFormatSnakeCaseKeys(line)函数仅使用内置的 Javascript 功能并返回转换为 JSON ...

    influxdb-tomcat-accesslog:将登录到 InfluxDB 数据库的 Tomcat 访问日志阀

    influxdb-tomcat-accesslog 将登录到 InfluxDB 数据库的 Tomcat 访问日志阀。 此实现旨在向添加 influxdb 支持。 Tomcat 的默认访问日志阀将访问日志记录到logs/localhost_access_log.TIMESTAMP.txt文件中。配置将...

    jboss中access 日志的配置

    deploy/jbossweb-tomcat55.sar/server.xml ... prefix="access_log." suffix=".log" pattern="%h %t %r %s %D" directory="${jboss.server.home.dir}/../output/logs" resolveHosts="false" /&gt; ...

    spring-boot-starter-purge-accesslog:Spring Boot应用程序的AccessLog清除策略

    用于Spring Boot应用程序的可清除AccessLog 为基于Spring Boot的应用程序启用访问日志文件清除功能的模块。 添加项目Lombok代理 该项目使用生成getter和setter等。从命令行编译应该不会引起任何问题,但是在IDE中,...

    Apach-Tomcat-access-log-parser:解析apache tomcat的访问日志的代码,该访问日志存储在命令行参数中给出的日志文件夹中

    Apach Tomcat访问日志解析器 解析存储在命令行参数中给出的日志文件夹中的Apache Tomcat的访问日志的代码,它从日志文件夹中的每个访问日志文件中读取日志条目,并使用JDBC将它们存储到Excel工作表中

    Nginx+Tomcat负载均衡

    access_log logs/access.log; client_header_timeout 3m; client_body_timeout 3m; send_timeout 3m; client_header_buffer_size 1k; large_client_header_buffers 4 4k; sendfile on; tcp_nopush on; ...

    tomcat8 + nginx + memcached + cas 实现负载均衡的配置包

    1,tomcat8的配置: 1.1修改tomcat8.x/conf/context.xml的配置如下: &lt;!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file ...

    详解nginx 配置多个tomcat共用80端口

    场景:项目1放在tomcat1中,项目2放在tomcat2中,两个tomcat放在同一台服务器上,需要共享80端口访问 注意:这里和集群部署是不同的,集群部署是一个项目放在多个tomcat中。... #access_log logs/host.acces

    Tomcat日志文件定时清理备份的脚本

    以下脚本主要备份的日志文件为tomcat的catalina.out、localhost_access_log.yyyy-mm-dd.log日志和项目的日志文件,其中项目的日志文件格式为”projectname-yyyy-mm-dd.log”,以下为备份脚本,具体的操作都有相应的...

    tomcat-mongo-access-log-console:查询mongodb中保存的tomcat访问日志的控制台

    Tomcat Mongo 访问日志控制台 本项目用于查询生成的。 用法 安装了 nodejs 和 npm。 将config.default.json复制到config.json 。 修改config.json设置和集合名称。 运行命令: npm install npm start # or ./...

    应用分析监控平台 闪电狗.zip

    先配置将tomcat日志输出到log4j,下载tomcat-juli.jar到tomcat/bin,覆盖原来的jar,下载tomcat-util.jar到tomcat/lib,复制log4mongo-java ,flash-dog-api-log4j 和 mongo-java-driver ,log4j.properties到lib 2....

    Nginx自定义访问日志的配置方式

    前言 Nginx日志主要分为两种:访问日志和错误...就我们普通的JAVAWEB项目来说,重要的日志一般输出并存放在Tomcat的log目录下,并区分日志输出级别。用于区分,查阅并统计相关日志信息。 当然,这不是重点,重点是很多

    配置好的nginx,Windows版本,解压即用只需稍微修改下service即可。

    #access_log logs/host.access.log main; # 静态页面目录 root E:\workSpace\本地静态资源; # 默认首页 index index.html; location = / { index login.html index.html index.htm; } # 用户浏览器端的...

    tomcat-5.5.23

    Change it to a port that isn't in use, and is greater than 1024, as ports less than or equal to 1024 require superuser access to bind under UNIX. &lt;br&gt; Restart Tomcat and you're in business...

    实战Nginx:取代Apache的高性能Web服务器 第一章

    5.1 Nginx与JSP(Tomcat)在Linux上的安装、配置 5.2 Nginx与ASP.NET(Mono+FastCGI)在Linux上的安装、配置 5.3 Nginx与Perl(FastCGI)在Linux上的安装、配置 第6章 Nginx HTTP负载均衡和反向代理的配置与优化 6.1...

    Logback日志系统文件

    分享的文件包括Logback的相关jar包和核心配置文件。 Logback是由log4j创始人设计的另一个开源日志组件,基于slf4j的日志... logback-access 模块与 Tomcat 和 Jetty 等 Servlet 容器集成,以提供 HTTP 访问日志功能。

    Nginx+Tomcat多站点部署的方法

    本文介绍了Nginx+Tomcat多站点部署的方法,分享给大家,具体如下: Tomcat配置: 添加多域名: Engine节点下: 添加域名1 unpackWARs=true autoDeploy=true&gt; ... prefix=localhost_access_log suffix=.txt p

    nginx 1.9 window 版本

    access_log /var/log/nginx/access.log; #sendfile 指令指定 nginx 是否调用 sendfile 函数(zero copy 方式)来输出文件,对于普通应用, #必须设为 on,如果用来进行下载等应用磁盘IO重负载应用,可设置为 off...

    实现自动定期删除Nginx日志的方法

    find /usr/local/nginx/logs/ -mtime +15 -type f -name *.log | xargs rm -f 上述脚本是将nginxlogs下面的15天之前的日志文件删除,可以参考上面的脚本删除其他程序(如PHP、Tomcat)的日志文件。不过使用脚本的...

Global site tag (gtag.js) - Google Analytics