Question

I am using JPA for my project ...

My question is : Whenever we are executing some query using the JPA the query is logged in the server.log file of the **JBOSS** . Am using Jboss log4J.

But i want to avoid printing the query in the server.log file . without changing the below property:

<property name="hibernate.show_sql" value="true"/>

Instead i tried :

<category name="org.hibernate">
        <priority value="ERROR" />
    </category>

in log4j.xml , eventhough queries are logging in the console or server.log for successfull query .

Can anyone please help me on this how to achieve this ... ?

Where i have to change the Configuration to avoid the query logging in the server.log ?

Was it helpful?

Solution

You might struggle to do this.

<property name="hibernate.show_sql" value="true"/>

Is really a development setting which writes the generated SQL to stdout not to your logger.

Take a look at org.hibernate.jdbc.util.SQLStatementLogger to confirm.

The logging of the SQL to your configured logging mechanism is an entirely different thing and is written to org.hibernate.SQL.

Therefore to avoid writing SQL anywhere you will need to set:

<property name="hibernate.show_sql" value="false"/>

and use the following log setting:

<category name="org.hibernate">
  <priority value="INFO" />
</category> 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top