Hibernate/seam:Hibernate.show\u sql设置 org.hibernate.ejb.HibernatePersistence ACM20DS

Hibernate/seam:Hibernate.show\u sql设置 org.hibernate.ejb.HibernatePersistence ACM20DS,hibernate,seam,weblogic-10.x,persistence.xml,jrebel,Hibernate,Seam,Weblogic 10.x,Persistence.xml,Jrebel,有时我会将hibernate.show\u sql设置为true 但是我必须重新启动应用服务器。我正在使用Weblogic 10和JRebel 是否可以在我需要的位置将hibernate.show_sql设置为true?您可以配置hibernate,通过现有的日志记录工具(如Log4j)执行日志记录,请参阅。在这种情况下,您可以使用日志记录工具在运行时控制Hibernate日志记录类别的日志级别 例如,在Log4j中: <persistence-unit name="acmDB" t

有时我会将
hibernate.show\u sql
设置为true

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


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

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

例如,在Log4j中:

   <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>

@Shervin:是的,但是如果更改它需要重新启动应用程序,op希望避免什么。这只是weblogic吗?因为在JBoss中,您不需要重新启动应用程序。JBoss将在一次测试后接收更改while@Shervinaxtavt的意思是Guus希望根据即将执行的代码以编程方式打开/关闭日志记录,这样他只能在日志中获得相关查询。嗨,我试过了,但没有看到hibernate调试行。我在课堂上使用Seam的
@Logger Log
。也许这就是原因?如果我让它工作起来,我就不必重新启动,因为我使用JRebel来获取更改。为了将来的参考,请参阅这个关于如何从特定查询获取SQL的答案。对于这个特定的问题来说,这可能有些过分,但这是我发现的捕获sql并将其与单个HQL、条件或方法调用联系起来的最好方法。
//Enable SQL logging
Logger.getLogger("org.hibernate.type").setLevel(Level.DEBUG);

//Disable SQL logging
Logger.getLogger("org.hibernate.type").setLevel(Level.OFF);