Tomcat日志记录(如apache)

时间:2011-05-02 19:46:03

标签: tomcat logging

我是Tomcat的新手并试图从这个论坛和网站上找到答案但是还没有成功,所以我在这里。

我想留下每次访问我的tomcat服务器,包括推荐,浏览器信息等我认为我从Apache获得(默认情况下?)。有没有办法在tomcat中做到这一点(最好是通过打开一些选项)。我查看了我的tomcat安装的logs目录,但是找不到类似于我正在寻找的东西。

1 个答案:

答案 0 :(得分:3)

如果我理解正确,请点击此处:http://wiki.apache.org/tomcat/FAQ/Logging#Q1

从第3个问题点开始,第一个问题:

 To enable request logging similar to the Apache HTTP server, you may include the 
 following line in the server.xml file, in the <Engine> tag:

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

 This will produce a log file for each day, such as 
 logs/localhost_access_log.2008-03-10.log, containing the files 
 requested, IP address of the requester, and similar information.

 128.34.123.121 - - [10/Mar/2008:15:55:57 -0500] "GET /upload/ClickPoints.jsp HTTP/1.1" 200 2725

希望有所帮助。