Tuesday, June 11, 2013

Logging Levels

In software development, logging is refers to recording the activities. There are several logging framework for java platform. 

Logging is divided into three pieces. 
1.Logger 
2. Formatter
3. Handler (Appender)

Logger is responsible for capturing the message to be  logged along with the initial meta-data. After receiving the message the framework calls the formatter with the message. The formatter formats it for the output.
Then the framework handle the formatted message to the appropriate appender for disposition. this might include in a console display.

The messages are logged in certain level. The following are the six logging levels used by log (in order).

1. FATAL : (Highest level) shows messages at a FATAL level only. This level is straightforward and you don't get it quite often. Once you get this level and it indicates application death. This shows the error messages that cause premature termination.

2. ERROR: This shows messages classified as ERROR and FATAL. This level gives information about a serious error which needs to be addressed and may result in unstable state. This level is one level higher than WARN.

3. WARN: This level shows messages classified as WARN, ERROR, and FATAL. This level gives a warning about an unexpected event to the user. This warning messages may not halt the progress of the system.

4. INFO: This level shows messages classified as INFO, WARN, ERROR, and FATAL. This level gives the progress and chosen state information. This level will be useful for end user. 

5. DEBUG: This shows messages classified as DEBUG, INFO, WARN, ERROR, and FATAL. This level helps developer to debug the application. This logged message will be focused on providing support to application developer.

6. TRACE :(Lowest level) Actually we don't use this level often. But this would be extremely for more detailed and potentially high volume logs. So you don't need typically enabled even during normal development.