tomcat的localhost_access_log日志文件

一、服务器打印日志
要关闭hibernate的日志,首先要把hibernate.show_sql设置为false;然后设置log4j.properties。

# Control logging for other open source packages
log4j.logger.com.opensymphony.oscache=ERROR
log4j.logger.net.sf.navigator=ERROR
log4j.logger.net.sf.acegisecurity=WARN
log4j.logger.net.sf.acegisecurity.intercept.event.LoggerListener=WARN
log4j.logger.org.apache.commons=ERROR
log4j.logger.org.apache.struts=WARN
log4j.logger.org.displaytag=ERROR
log4j.logger.org.springframework=WARN
log4j.logger.com.ibatis.db=WARN
log4j.logger.org.apache.velocity=WARN

# Don't show debug logs for WebTest
log4j.logger.com.canoo.webtest=WARN

# All hibernate log output of "info" level or higher goes to stdout.
# For more verbose logging, change the "info" to "debug" on the last line.
log4j.logger.org.hibernate.ps.PreparedStatementCache=WARN
log4j.logger.org.hibernate=WARN

# Changing the log level to DEBUG will result in Hibernate generated
# SQL to be logged.
log4j.logger.org.hibernate.SQL=ERROR

# Changing the log level to DEBUG will result in the PreparedStatement
# bound variable values to be logged.
log4j.logger.org.hibernate.type=ERROR
二、tomcat的localhost_access_log日志文件
 

  tomcat的logs目录下除了有catalina.out日志文件外,还有个localhost_access_log.yyyy-MM-dd.txt的日志文件。生成这个文件的配置在tomcat的安装目录conf文件夹下server.xml里配置。

   

 

       这个日志文件可记录所有http的get,post访问日志。比如我要查询某个index.action某天是否访问过我这个tomcat,可以执行如下命令:grep “index.action” localhost_access_log.2015-03-23.txt。输出如下:

192.168.10.51 – – [23/Mar/2015:17:27:28 +0800] “GET /finance/index.action?0.8436781843192875 HTTP/1.0” 200 2 0.011

192.168.10.51 – – [23/Mar/2015:17:27:58 +0800] “GET /index.action?0.9197160941548645 HTTP/1.0” 200 2 0.013

如果访问过那么相应的ip地址,访问时间,请求方式(get,post),请求action名称…..都会输出来。这样有利于我们排查一些问题,还可以采集、存储、分析日志数据得到有价值的东西。

posted @ 2017-08-25 16:34  小明猿  阅读(34061)  评论(0编辑  收藏  举报