1

我正在为我的项目使用 JPA ...

我的问题是:Whenever we are executing some query using the JPA the query is logged in the server.log file of the **JBOSS** .我正在使用 Jboss log4J。

但我想避免在 server.log 文件中打印查询。在不更改以下属性的情况下:

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

相反,我尝试了:

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

log4j.xml ,即使查询正在控制台或 server.log 中记录以进行成功查询。

谁能帮我解决这个问题……?

我必须在哪里更改配置以避免 server.log 中的查询记录?

4

1 回答 1

1

你可能很难做到这一点。

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

确实是一个开发设置,它将生成的 SQL 写入标准输出而不是您的记录器。

看一看org.hibernate.jdbc.util.SQLStatementLogger确认。

将 SQL 记录到您配置的日志记录机制是完全不同的事情,并且写入org.hibernate.SQL.

因此,为了避免在任何地方编写 SQL,您需要设置:

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

并使用以下日志设置:

<category name="org.hibernate">
  <priority value="INFO" />
</category> 
于 2012-09-04T13:49:54.120 回答