English 中文(简体)
SLF4J - Logging Frameworks
  • 时间:2024-12-22

SLF4J - Logging Frameworks


Previous Page Next Page  

Logging in programming, refers to recording activities/events. Usually, the apppcation 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 apppcation 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 psts down the general levels of logging.

Sr.No Severity level & Description
1

Fatal

Severe issue that causes the apppcation 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.

Advertisements