Johan's blog
Debugging Persistence in Glassfish
When developing JavaEE applications, I consider the server.log to be the most important feedback. No matter how many tools exist (I recently wrote about using NetBeans , and I'm still happy with it), the combination of server-information and my own System.out.println's has often proved to be my personal way of debugging applications.
Depending on the type of application I am working at, I use different loglevels for different components. At this moment, I have every loglevel set to INFO, except for the Persistence module, where I use the loglevel "FINE". This will cause all SQL queries to be printed in the logfile. In case some output is not what I expected, I check the SQL query that should retrieve the results. That solves my problem in most of the cases.
Seeing the SQL output is also very useful for performance evaluation. Although there do exist great tools for analyzing hot spots in code, a manual "intuitive" high-level look at the number of queries helps me in deciding what parts of code are first candidates for optimization.
In order to change loglevels with the Glassfish Application Server, log in into the admin console (e.g. http://localhost:4848), select "Application Server", "Logging", "Log Levels" and change the values you want to change. Be careful, if you use "FINEST" for all modules, your hard disk might be too small soon
