`

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  
不错, 很管用。
多谢!

相关推荐

    tomcat5.5 log配置所需文件

    以下是关于"Tomcat 5.5 Log配置"的知识点详解: 1. **Log4j**: 标签中提到的"log4j.jar"是Apache的一个开源项目,它为Java应用程序提供了一个灵活的日志框架。Log4j是Tomcat默认使用的日志系统,允许开发者根据需要...

    tomcat配置log4j

    **标题:“Tomcat配置Log4j”** 在Java Web开发中,日志记录是一个至关重要的环节,它能够帮助开发者追踪程序运行状态、定位错误和调试问题。Tomcat,作为广泛使用的开源Servlet容器,通常需要与日志框架集成,Log4...

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

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

    Nginx+Tomcat负载均衡配置教程

    # access_log logs/access.log main; # 设置超时时间 client_header_timeout 3m; client_body_timeout 3m; send_timeout 3m; # 缓冲区大小 client_header_buffer_size 1k; large_client_header_buffers 4 4k; # ...

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

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

    nginx和tomcat配置SSL和负载均衡配置

    access_log /var/log/nginx/access.log main; keepalive_timeout 120; # SSL 配置 server { listen 443 ssl http2; server_name example.com www.example.com; ssl_certificate /path/to/your/certificate....

    tomcat日志配置.docx

    本文将详细介绍 Tomcat 的日志配置,包括日志开关文件、日志信息、修改日志级别和使用 Log4j 记录应用程序日志或系统日志。 一、Tomcat 中的日志开关文件 Tomcat 中的日志开关文件是 logging.properties,位于 ...

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

    Tomcat 6.0配置

    &lt;Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/&gt; ``` #### 三、web.xml文件配置 `web...

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

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

    Tomcat配置文件

    标题中的“Tomcat配置文件”指的是Tomcat服务器的配置文件`server.xml`,它是Tomcat容器的核心配置文件,用于定义服务器的行为、端口、虚拟主机、应用上下文等。描述中提到的问题是当项目数量增多时,直接在`server....

    Linux下配置Tomcat日志分析

    例如,如果你的Tomcat日志文件位于`/var/log/tomcat/access.log`,则需要将`LogFile`设置为这个路径。 ```config # Your website domain name SiteDomain="yourdomain.com" # Path to web server log file LogFile...

    tomcat安装及配置教程 Linux下Tomcat+Nginx服务器环境安装配置简明教程.docx

    ` access_log /home/renhetoutiao/renhetoutiao/logs/access_log.log;` ` location = / {` ` rewrite ^/$ /index.shtml last;` ` }` ` location ~ .shtml {` ` proxy_pass http://localhost:8081;` ` proxy_set_...

    tomcat配置虚拟主机

    ### Tomcat配置虚拟主机详解 #### 一、前言与准备 在Web开发与部署过程中,经常需要在同一个服务器上运行多个不同的Web应用程序。为了更好地管理和区分这些应用程序,可以通过配置虚拟主机来实现这一目标。虚拟...

    linux安装nginx+keepalived,和tomcat负载均衡配置,动静分离配置,主备和双主模式

    access_log off; # 关闭访问日志 expires 30d; # 设置缓存时间 } } } ``` 完成配置后,重启Nginx和Keepalived服务: ```bash sudo systemctl restart nginx sudo systemctl restart keepalived ``` 至此,你...

    在tomcat的访问日志配置:awstats

    &lt;Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="access_log" suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" /&gt; ``` 至于AWStats的配置,首先需要下载并解压...

    tomcat安装及配置教程

    - 定期查看`logs/catalina.out`、`logs/access_log.*`等文件。 - 发现异常请求或性能瓶颈。 综上所述,从Tomcat的基础安装到高级配置,再到性能优化及监控,每一环节都至关重要。正确配置能够显著提高Tomcat...

Global site tag (gtag.js) - Google Analytics