1. 程式人生 > >[DEBUG] 2018-12-06 11:10:24,007 method:org.hibernate.loader.plan.build.spi.LoadPlanTreePrinter.logTr

[DEBUG] 2018-12-06 11:10:24,007 method:org.hibernate.loader.plan.build.spi.LoadPlanTreePrinter.logTr

記住:如果不是程式有問題的話,就是配置的log4j.properties檔案有問題;

第一步:jar包,有如下三個jar包(沒有的話,給我留言,我發給你)

 第二步,在src包下面新建一個file,命名為log4j.properties

內容如下:

#
# Hibernate, Relational Persistence for Idiomatic Java
#
# License: GNU Lesser General Public License (LGPL), version 2.1 or later.
# See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
#
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
#log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L (hibernateLoadPlanWalkPath->%X{hibernateLoadPlanWalkPath}) - %m%n

#log4j.appender.stdout-mdc=org.apache.log4j.ConsoleAppender
#log4j.appender.stdout-mdc.Target=System.out
#log4j.appender.stdout-mdc.layout=org.apache.log4j.PatternLayout
#log4j.appender.stdout-mdc.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L (walk path -> %X{hibernateLoadPlanWalkPath}) - %m%n

log4j.appender.unclosedSessionFactoryFile=org.apache.log4j.FileAppender
log4j.appender.unclosedSessionFactoryFile.append=true
log4j.appender.unclosedSessionFactoryFile.file=target/tmp/log/UnclosedSessionFactoryWarnings.log
log4j.appender.unclosedSessionFactoryFile.layout=org.apache.log4j.PatternLayout
log4j.appender.unclosedSessionFactoryFile.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

log4j.rootLogger=info, stdout

#log4j.logger.org.hibernate.loader.plan=trace, stdout-mdc
#log4j.additivity.org.hibernate.loader.plan=false
#log4j.logger.org.hibernate.persister.walking=trace, stdout-mdc
#log4j.additivity.org.hibernate.persister.walking=false

log4j.logger.org.hibernate.tool.hbm2ddl=trace
log4j.logger.org.hibernate.testing.cache=debug

# SQL Logging - HHH-6833
log4j.logger.org.hibernate.SQL=debug

log4j.logger.org.hibernate.type.descriptor.sql.BasicBinder=trace
log4j.logger.org.hibernate.type.descriptor.sql.BasicExtractor=trace

log4j.logger.org.hibernate.hql.internal.ast=debug

log4j.logger.org.hibernate.sql.ordering.antlr=debug

log4j.logger.org.hibernate.loader.plan2.build.internal.LoadPlanImpl=debug
log4j.logger.org.hibernate.loader.plan2.build.spi.LoadPlanTreePrinter=debug
log4j.logger.org.hibernate.loader.plan2.exec.spi.EntityLoadQueryDetails=debug

log4j.logger.org.hibernate.engine.internal.StatisticalLoggingSessionEventListener=info

log4j.logger.org.hibernate.boot.model.source.internal.hbm.ModelBinder=debug
log4j.logger.org.hibernate.type.descriptor.java.JavaTypeDescriptorRegistry=debug
log4j.logger.org.hibernate.action.internal.EntityAction=debug

log4j.logger.org.hibernate.engine.internal.Cascade=trace

### When entity copy merge functionality is enabled using: 
### hibernate.event.merge.entity_copy_observer=log, the following will 
### provide information about merged entity copies.
### log4j.logger.org.hibernate.event.internal.EntityCopyAllowedLoggedObserver=debug

log4j.logger.org.hibernate.testing.junit4.TestClassMetadata=info, unclosedSessionFactoryFile
log4j.logger.org.hibernate.boot.model.process.internal.ScanningCoordinator=debug

log4j.logger.org.hibernate.cache trace
log4j.logger.org.hibernate.stat trace

然後就ok了