”;
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.
Logging Framework Overview
A logging framework usually contains three elements −
Logger
Captures the message along with the metadata.
Formatter
Formats the messages captured by the logger.
Handler
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.
Logger Object
To log a message, the application sends a logger object (sometimes along with the exceptions if any) with name and security level.
Severity Level
The messages logged will be of various levels. The following table lists down the general levels of logging.
Sr.No | Severity level & Description |
---|---|
1 |
Fatal Severe issue that causes the application to terminate. |
2 |
ERROR Runtime errors. |
3 |
WARNING In most cases, the errors are due to the usage of deprecated APIs. |
4 |
INFO Events that occur at runtime. |
5 |
DEBUG Information about the flow of the system. |
6 |
TRACE More detailed information about the flow of the system. |
”;