1
   <persistence-unit name="acmDB" transaction-type="RESOURCE_LOCAL">
      <provider>org.hibernate.ejb.HibernatePersistence</provider>
      <jta-data-source>acm20-ds</jta-data-source>
      <properties>
         <property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect"/>
         <property name="hibernate.hbm2ddl.auto" value="update"/>
         <property name="hibernate.show_sql" value="false"/>
         <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
         <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.WeblogicTransactionManagerLookup"/>         
      </properties>
   </persistence-unit>

有时我设置hibernate.show_sql为 true

但是我必须再次重新启动应用程序服务器。我正在使用 Weblogic 10 和 JRebel。

是否可以hibernate.show_sql在我需要的位置的代码中设置为 true?

4

1 回答 1

2

您可以配置 Hibernate 以通过现有的日志记录工具(例如 Log4j)执行日志记录,请参见3.5。记录。在这种情况下,您可以使用您的日志记录工具在运行时控制 Hibernate 日志记录类别的日志级别。

例如,在 Log4j 中:

//Enable SQL logging
Logger.getLogger("org.hibernate.type").setLevel(Level.DEBUG);

//Disable SQL logging
Logger.getLogger("org.hibernate.type").setLevel(Level.OFF);
于 2011-02-01T10:11:46.010 回答