I’m getting acquainted with Wicket (which I blogged about here). In doing so, I encountered some problems and got a few responses from Wicket’s mailing list. Someone suggested that I use Log4j to debug my issues, and so — for the first time — I used Log4j today. So here, as a reminder to myself and possibly of benefit to others, is what I did to use Log4j for debugging a Wicket application deployed over Tomcat from NetBeans IDE:
- Stop the running Tomcat instance. (In the IDE’s Runtime window.)
- Download Commons Logging and copy the JAR to Tomcat’s common/lib folder.
- Download Log4j and copy the JAR to Tomcat’s common/lib folder.
- Create a log4j.properties file in Tomcat’s common/classes folder. Make sure it contains the following line:
The above line is only for the resource package. To enable debugging for all the Wicket packages, use this instead:
This is my log4j.properties file. Make sure that you change the log4j.appender.R.File property to point to logs/tomcat.log file in Tomcat’s base directory (which is inside the NetBeans IDE user directory).
- Deploy the Wicket application. (In the IDE’s Projects window.)
- Go to the logs/tomcat.log file in Tomcat’s base directory and, if errors have been picked up, note that there are lines such as the following:
2005-07-02 20:41:25,140 [http-8084-Processor23]
DEBUG wicket.util.resource.locator.ResourceStreamLocator -
Attempting to locate resource 'wicket/examples/navomatic/Page1.html'
on path [folders = [\], webapppaths: ]
Finally, I’ve found this document to be very helpful in setting up Log4j for Tomcat: Logging for Apache Tomcat and Velocity using Log4j