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 "%r" %s %b %D"
-
combined
:
pattern="combined"
-
combined plus response time
:
pattern="%h
%l %u %t "%r" %s %b "%{Referer}i"
"%{User-Agent}i" %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.
分享到:
相关推荐
以下是关于"Tomcat 5.5 Log配置"的知识点详解: 1. **Log4j**: 标签中提到的"log4j.jar"是Apache的一个开源项目,它为Java应用程序提供了一个灵活的日志框架。Log4j是Tomcat默认使用的日志系统,允许开发者根据需要...
**标题:“Tomcat配置Log4j”** 在Java Web开发中,日志记录是一个至关重要的环节,它能够帮助开发者追踪程序运行状态、定位错误和调试问题。Tomcat,作为广泛使用的开源Servlet容器,通常需要与日志框架集成,Log4...
一、配置与说明 tomcat访问日志格式配置,在config/server.xml里Host标签下加上 prefix=localhost_access_log. suffix=.txt pattern=%h> 我们在日志文件中将看到如下文本: 10.217.14
# 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 的默认访问日志阀将访问日志记录到logs/localhost_access_log.TIMESTAMP.txt文件中。配置将...
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 的日志配置,包括日志开关文件、日志信息、修改日志级别和使用 Log4j 记录应用程序日志或系统日志。 一、Tomcat 中的日志开关文件 Tomcat 中的日志开关文件是 logging.properties,位于 ...
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" /> ...
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/> ``` #### 三、web.xml文件配置 `web...
用于Spring Boot应用程序的可清除AccessLog 为基于Spring Boot的应用程序启用访问日志文件清除功能的模块。 添加项目Lombok代理 该项目使用生成getter和setter等。从命令行编译应该不会引起任何问题,但是在IDE中,...
标题中的“Tomcat配置文件”指的是Tomcat服务器的配置文件`server.xml`,它是Tomcat容器的核心配置文件,用于定义服务器的行为、端口、虚拟主机、应用上下文等。描述中提到的问题是当项目数量增多时,直接在`server....
例如,如果你的Tomcat日志文件位于`/var/log/tomcat/access.log`,则需要将`LogFile`设置为这个路径。 ```config # Your website domain name SiteDomain="yourdomain.com" # Path to web server log file LogFile...
` access_log /home/renhetoutiao/renhetoutiao/logs/access_log.log;` ` location = / {` ` rewrite ^/$ /index.shtml last;` ` }` ` location ~ .shtml {` ` proxy_pass http://localhost:8081;` ` proxy_set_...
### Tomcat配置虚拟主机详解 #### 一、前言与准备 在Web开发与部署过程中,经常需要在同一个服务器上运行多个不同的Web应用程序。为了更好地管理和区分这些应用程序,可以通过配置虚拟主机来实现这一目标。虚拟...
access_log off; # 关闭访问日志 expires 30d; # 设置缓存时间 } } } ``` 完成配置后,重启Nginx和Keepalived服务: ```bash sudo systemctl restart nginx sudo systemctl restart keepalived ``` 至此,你...
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> ``` 至于AWStats的配置,首先需要下载并解压...
- 定期查看`logs/catalina.out`、`logs/access_log.*`等文件。 - 发现异常请求或性能瓶颈。 综上所述,从Tomcat的基础安装到高级配置,再到性能优化及监控,每一环节都至关重要。正确配置能够显著提高Tomcat...