Using Log4J with Hibernate Step 30
To help you debug your application, it is good to set up a log4j properties file so you can see the queries that hibernate is executing. This will help you to know if your hibernate mappings are correct.
In your build file, you need to include this line of code.
<classes dir="${CONFIG}/properties" />
You will put this code within your war file tag. This code will include your properties file when building your war file.
You should already have a folder called config, but if you don't, you should create one. In that folder you should create a folder called properties and in that folder you should create a file called log4j.properties.
Paste the following code in that file:
log4j.rootCategory=INFO, A1
log4j.category.org.hibernate.SQL=TRACE, A1
log4j.category.org.hibernate.type=TRACE, A1
log4j.categoty.org.apache.struts.tiles=INFO, A1
log4j.additivity.org.hibernate.SQL=false
log4j.additivity.org.hibernate.type=false
log4j.category.org.josso=INFO, A1
log4j.additivity.org.josso=false
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-5p [%x] - %m%n
This is an example log file. This code sets some hibernate logging parameters that will allow you to debug your hibernate issues.
Go To Step 31

0 comments:
Post a Comment