Log Levels in Application

Log levels or Logging Levels are processes to categorize the importance or severity of messages logged in software or applications. They are also called log severity levels. They allow developers to configure what types of messages are logged and their importance based on the SLA of the system.

Application logging is an important thing to consider when you write production-grade code. It helps in debugging the code as well as fixing any issues that come up in production. It provides an archaeological record of the application behavior in production.

A log file can tell you if an application has failed or faced a memory error in production. It can have important information like timestamps, messages, and logging levels of the logs.

Common Logs Levels

The below table gives some common log levels in terms of their hierarchy that are used by many logging libraries.

Log LevelDescriptions
OFFDon’t Log Anything. It is the highest possible rank and is intended to turn off logging.
FATALIt represents very severe error events that will presumably lead the application to abort or crash or database corruption.
ERRORGives error events that might still allow the application to continue running.
WARNGives information about harmful situations in applications.
INFOIt contains informational messages that are logged in the application.
DEBUGIt provides fine-grained informational events that are most useful to debug an application.
TRACEGives finer-grained informational events than the DEBUG.
ALLIt logs everything, including any custom logging levels in the application.

Common Logging Library

There are different log levels in applications based on what programming languages and libraries are being used. Some of the most popular libraries that I have worked with are given below.

  • Log4j
  • Logback
  • Apache Common Logging Framework
  • Java Logging API
  • SL4J framework