如何使hbm2ddl schemaExport将模式记录到stdout?

yeg*_*256 15 java orm hibernate hbm2ddl

引用自persistence.xml:

<persistence-unit name="test" transaction-type="RESOURCE_LOCAL">
    <properties>
        <property name="hibernate.archive.autodetection" value="class" />
        <property name="hibernate.show_sql" value="true" />
        <property name="hibernate.format_sql" value="true" />
        <property name="hibernate.hbm2ddl.auto" value="create" />
        ...
    </properties>
</persistence-unit>
Run Code Online (Sandbox Code Playgroud)

这是我在日志输出中看到的:

Sep 30, 2010 12:03:43 PM org.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: Running hbm2ddl schema export
Sep 30, 2010 12:03:43 PM org.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: exporting generated schema to database
Sep 30, 2010 12:03:43 PM org.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: schema export complete
Run Code Online (Sandbox Code Playgroud)

但我没有看到模式(SQL)导出自己.如何从Hibernate(3.5.6-Final)获取此信息?

Pas*_*ent 16

激活org.hibernate.tool.hbm2ddl类别的日志记录DEBUG.


更新:这是一个简化的logback.xml(我使用logback作为日志记录后端):

<configuration scan="true">

  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <layout class="ch.qos.logback.classic.PatternLayout">
      <Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
    </layout>
  </appender>

  <!-- ### log just the SQL ### -->
  <logger name="org.hibernate.SQL" level="DEBUG"/>

  <!-- ### log JDBC bind parameters ### -->
  <logger name="org.hibernate.type" level="TRACE"/>

  <logger name="org.hibernate.tool.hbm2ddl" level="DEBUG"/>

  <root level="ERROR">
    <appender-ref ref="STDOUT"/>
  </root>
</configuration>
Run Code Online (Sandbox Code Playgroud)

如果你使用log4j,你可以调整它(你可以在SO上找到工作配置).


sch*_*eld 6

以防你使用Spring Boot偶然发现这个问题.您可以在以下位置配置以下内容application.yml:

spring.jpa:
  hibernate.ddl-auto: create-drop
logging.level:               
  org.hibernate.tool.hbm2ddl: DEBUG
  org.hibernate.SQL: DEBUG   
  org.hibernate.type: TRACE  
Run Code Online (Sandbox Code Playgroud)