---
title: "如何关闭hibernate产生的大量日志"
author: "forever8tf"
date: "2011-05-19T15:53:14Z"
tags: ["Apache", "Hibernate", "SQL", "iBATIS", "log4j"]
categories: ["企业架构"]
slug: "hibernate"
draft: false
lastmod: "2011-05-19T15:53:14Z"
id: 1050398
url: "https://forever8tf.iteye.com/blog/1050398"
---

要关闭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

 

转自： [http://tianke66.iteye.com/blog/332930](http://tianke66.iteye.com/blog/332930)

确实好用，直接转过来了。