Here's a little snippet from my book, Hibernate Made Easy:
Quote:
Setting up log4J
You will also notice a little log4J error message in my output:
log4j:WARN No appenders could be found for logger
log4j:WARN Please initialize the log4j system properly.
This error is due to the fact that Hibernate is using Log4J, and a properties file that Log4J uses to initialize itself cannot be found on the classpath. The Hibernate download contains a sample log4J.properties file you can place on your classpath that will eliminate this error message and subsequently direct logging entries to the System.out log. Alternatively, you can create your own log4J.properties file with the following settings:
##########################################
### direct log messages to stdout ###
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
### set log levels - ###
log4j.rootLogger=warn, stdout log4j.logger.org.hibernate=info
### log JDBC bind parameters ###
log4j.logger.org.hibernate.type=debug
### log schema export/update ###
log4j.logger.org.hibernate.tool.hbm2ddl=debug
##########################################
Make sure the file is named log4j.properties, and is placed on the classpath of both the JVM, and the classloader that creates the AnnotationConfiguration object; for me, the log4j.properties file gets placed in the C:\_mycode folder, alongside the all important hibernate.cfg.xml file. Add in this properties file, and then you’ll get all sorts of crazy log messages!
But the problem isn't the log messages, the big problem is that hbiernate.cfg.xml can't be found. It's not good enough to put it on the classpath. It must also be on the classpath of the classloader that initializes your Hibernate Configuration or AnnotationConfiguration object.
You might find this tutorial on how to set up Hibernate on a Windows XP system helpful. It has many examples and shows you the simplest Hibernate configuration possible:
http://www.thebookonhibernate.com/HiberBookWeb/learn.jsp?tutorial=01howtogetstartedwithhibernate