Set up log4j

I always prefer setting up log4j right from the start, because it will show you anything that is wrong with your application and can save you hours of googling and trying to solve issues that log4j will just report to you if you configure it properly (I am unhappy to inform you that I learned this the hard way, again. I have just been pulling my hair out over a 'SEVERE: Error listenerStart' error when starting the application, which turned out to be caused by an error in the application-context.xml file. Don't tell anyone, or they'll think I'm a beginner at this :))

Ok, to set up log4j, just put a file on the classpath. That is all. I have put it in the resources folder of the application, because that is where I like it to be. In my log4j I put the following content.

log4j.rootLogger=INFO, A1

# Print the date in ISO 8601 format
#log4j.appender.A1.layout.ConversionPattern=%d %-5p - %m%n
log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n

This will have log4j log messages to the Tomcat console.

log4j application start log

After configuring log4j, the application startup process will be much more verbose. Spring will log any errors it encounters in your setup, saving you (and myself) a lot of guess work.