我正在尝试将 logback 与 hibernate 一起使用,看起来很简单,但我无法让它工作
休眠.cfg.xml
<!-- DB Properties -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<property name="hibernate.current_session_context_class">thread</property>
<!-- DB Connection -->
<property name="hibernate.connection.url"> XXXXXXXXXXXXX</property>
<property name="connection.username">XXXXXXXXXX</property>
<property name="connection.password">XXXXXXXXXX</property>
<!-- c3p0 config -->
<property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="hibernate.c3p0.acquire_increment">1</property>
<property name="hibernate.c3p0.idle_test_period">100</property>
<property name="hibernate.c3p0.min_size">10</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.timeout">1800</property>
</session-factory>
logback.xml
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>%d{yyyy-MM-dd_HH:mm:ss.SSS} %-5level %logger{36} - %msg%n
</Pattern>
</encoder>
</appender>
<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>c:/timesheet.log</file>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>%d{yyyy-MM-dd_HH:mm:ss.SSS} [%thread] %-5level %logger{36} -
%msg%n
</Pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<FileNamePattern>c:/timesheet.%i.log.zip</FileNamePattern>
<MinIndex>1</MinIndex>
<MaxIndex>10</MaxIndex>
</rollingPolicy>
<triggeringPolicy
class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>2MB</MaxFileSize>
</triggeringPolicy>
</appender>
<logger name="org.hibernate" level="ALL"/>
<root level="INFO">
<appender-ref ref="FILE" />
<appender-ref ref="STDOUT" />
</root>
控制台输出
Hibernate: select this_.id_utente as id1_2_3_, this_.valido as valido2_3_, aziendagru2_.id_azienda_gruppo as id1_0_0_, aziendagru2_.logo as logo0_0_, aziendagru2_.nome_azienda as nome3_0_0_, aziendagru2_.sottotitolo_due as sottotit4_0_0_, aziendagru2_.sottotitolo_uno as sottotit5_0_0_, livello3_.id_livello as id1_3_1_ , livello3_.descrizione as descrizi2_3_1_, utentianag4_.id_utente_anagrafica as id1_1_2_, utentianag4_.cognome as cognome1_2_, utentianag4_.nome as nome1_2_ from ts_utenti this_ left outer join ts_aziende_gruppo aziendagru2_ on this_.id_azienda_gruppo=aziendagru2_.id_azienda_gruppo left outer join ts_livelli livello3_ on this_.id_livello= livello3_.id_livello 左外连接 ts_utenti_anagrafica utentianag4_ on this_.id_utente_anagrafica=utentianag4_.id_utente_anagrafica where this_.username=? 和 this_.password=?