Chapter 9. Logging, Debugging, Monitoring, and Profiling


9. Logging, Debugging, Monitoring, and Profiling

LOGGING IS AN IMPORTANT ISSUE that sometimes doesn't get the attention it deserves in various projects. Logging can be used for debugging, troubleshooting, tracing, or audit trail purposes. Logging can range from simple print statements to complex database or remote logging. Finding a good logging solution is key, preferably one that provides options such as control of output by severity level, formatting options, and the destination (for example, file or database).

Debugging, on the other hand, is necessary when bugs in a system are discovered, whether we like them or not. Bugs are software defects. Defects can surface for a variety of reasons, such as logic flaws in the code, wrong requirements, data problems, mismatch with an external interface (messaging service, for example), wrong versions of dependencies (for example, a third-party JAR file), invalid hardware/software combinations, and other reasons. The idea behind a defect is to locate the source of the defect and fix it! However, some defects can be harder to track down than others. Whereas one might take a couple of minutes to detect and fix, others can take days, typically, depending on the complexity of the system. The worst ones, in my opinion, are ones that are hard to reproduce or are intermittent in nature. (These drive me crazy!) Defects also vary in severity; some are minor UI aesthetics related and others are severe show-stoppers that can cause enormous amounts of financial damage to an organization, as a result of unavailable functionality. In short, a defect is something that fails to meet a customer requirement, and so, when defects surface, we need to find and fix them.

Debugging is typically the process of locating and fixing a defect, although it can sometimes be used to step through code to ensure the logic works correctly. Locating and fixing defects is perhaps one of the most difficult and frustrating tasks for a software developer. What can make this even worse is if you are debugging someone else's code.

Aside from logging and debugging, an application can have other design defects related to nonfunctional requirements (performance and scalability, for example). Monitoring and profiling an application can help meet such requirements by helping discover bottlenecks in an application related to memory consumption, CPU utilization, garbage collection, and so on. The Java Platform Standard Edition (JSE) 5.0 provides remote monitoring and management along with a nice GUI console that graphically displays information about the application being monitored.

In this chapter, I hope to provide you with some guidance on logging, debugging, monitoring, and also a bit on profiling.



Agile Java Development with Spring, Hibernate and Eclipse
Agile Java Development with Spring, Hibernate and Eclipse
ISBN: 0672328968
EAN: 2147483647
Year: 2006
Pages: 219

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net