Thursday, August 26, 2010

Logging

Logging is often underutilized in development companies. When an organization really understands the value of logging it will reduce the maintenance cost of code dramatically.

What is a log? A log is a short message that an application stores to give a maintainer information about what is happening behind the scenes (behind the user interface). Logs are generally stored in a file or a database so that they can be read and/or searched to find information about the running system.

Logging should be broken up into levels; each level having a specific and distinct purpose. In general those levels are as follows:

  1. Unrecoverable Problems: When something occurs that causes the entire system or application to cease running unexpectedly. When this occurs the log should get as much information about the state of the system and, if possible, the factors that caused the problem. This is generally difficult or impossible to capture because if a contingency plan was possible to implement it would be a level 2 problem.
  2. Undesirable but Recoverable Problems: When something unexpected occurs, but the system is able to recover, and return to normal operation. This type of problem is often caused by a necessary part of the system becoming unavailable. If a recovery is possible it is usually done by waiting, reinitializing part of the system, or switching to an alternate of the element that failed.
  3. Normal System Operations: While the system is running it is often useful to get information that allows a maintainer to verify that the system is running as expected. This is often information about periodic state of the system, or significant operations being completed.
  4. Major Module Operations: This level is used to monitor the normal operations of a module. It is generally not included in normal operation logs, but is useful to monitor the operation of individual modules while the system is being tested.
  5. Major Feature Operations: This level is used to monitor the normal operations of a feature. It is generally not included in normal operation logs, but is useful to monitor the operation of individual features while the system is being tested.
  6. Minor Feature Operations: This level is used to monitor the fine details of a feature. It is not included in normal operation logs, but is useful to monitor the fine details of a feature while the system is being tested.
  7. Line by Line Changes: This level logs information about each non-trivial variable change. This is generally only useful when attempting to debug.

1 comment:

  1. Also consider: http://download.oracle.com/javase/6/docs/api/java/util/logging/Level.html

    ReplyDelete