This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Other JSE/JEE APIs and the fly likes How to supress SQL Queries in log file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "How to supress SQL Queries in log file" Watch "How to supress SQL Queries in log file" New topic

How to supress SQL Queries in log file

shyam sunder prasad
Ranch Hand

Joined: Mar 23, 2011
Posts: 62
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j="">
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Threshold" value="info"/>
<param name="Target" value="System.out"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ABSOLUTE} [%t] %-5p %c{1} - %m%n"/>
<filter class="org.apache.log4j.filter.ExpressionFilter">
<param name="Expression" value="EXCEPTION ~= org.hibernate.LazyInitializationException"/>
<param name="AcceptOnMatch" value="false"/>
<priority value ="warn" />
<appender-ref ref="console" />
<!--<appender-ref ref="rolling-file" />

this is my log4j.xml file,
can you help me out how to supress sql statements in log4j and i am getting some warnings like log4j is not initialized properly.

Suresh Vadivel

Joined: Apr 12, 2010
Posts: 2
I hope you are using Hibernate and getting SQL queries also printed in log file.
If this is the case, Please make the show_sql property as false in hibernate config file. This will turn off the feature of sql getting printed.
I agree. Here's the link:
subject: How to supress SQL Queries in log file
Similar Threads
Unable to get logging working in Tomcat application
How to use log4j.jdbcplus.JDBCAppender in log4j.xml
Log4j : specific class to log on FileAppender other classes log on Console Appender.
how to disable the log
log4j with xml config file