Logging in programming, refers to recording activities/events. Usually, the application developers should take care of logging.
To make the job of logging easier, Java provides various frameworks − log4J, java.util.logging (JUL), tiny log, logback, etc.
A logging framework usually contains three elements −
Captures the message along with the metadata.
Formats the messages captured by the logger.
The Handler or appender finally dispatches the messages either by printing on the console or, by storing in the database or, by sending through an email.
Some frameworks combine the logger and appender elements to speed up the operations.
To log a message, the application sends a logger object (sometimes along with the exceptions if any) with name and security level.
The messages logged will be of various levels. The following table lists down the general levels of logging.
|Sr.No||Severity level & Description|
Severe issue that causes the application to terminate.
In most cases, the errors are due to the usage of deprecated APIs.
Events that occur at runtime.
Information about the flow of the system.
More detailed information about the flow of the system.