James Dekker wrote:The new problem I am having is that whereas this code does work and generate a table named User in the database, the logging isn't properly set up:
I wrote this log4j.properties file and placed it under $PROJECT_DIR_ROOT and also put it under Eclipse's build path (and it still doesn't work):
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
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 core 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=info
### 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 the JVM. Then you'll get all sorts of crazy log messages!
into PROJECT_DIR/classes using Eclipse (
I never knew about this because I always rely on an Ant build script which compiles, zips into a WAR file, and then deploys.
Space seems cool in the movies, but once you get out there, it is super boring. Now for a fascinating tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|