Logging

Logging is an essential part of any production-ready application.

Introducció

SLF4j

The SLF4J or the Simple Logging Facade for Java is an abstraction layer for various Java logging frameworks, like Log4j 2 or Logback. This allows for plugging different logging frameworks at deployment time without the need for code changes.

To enable SLF4J in your project you need to include the slf4j-api library and logging framework of your choice.

Since kotlin-logging depends on slf4j-api, which itself is a wrapper for different logging backends, we’re going to need a configuration. When we only need to log statements to standard output during development, we include org.slf4j:slf4j-simple.

SLF4J Tutorial

For production environments, however, we use Logback or Log4j2.

TODO