SLF4J - Environment Setup

In this chapter, we will explain how to set SLF4J environment in Eclipse IDE. Before proceeding with the installation, make sure that you already have Eclipse installed in your system. If not, download and install Eclipse.

For more information on Eclipse, please refer our Eclipse Tutorial

Step 1: Download the dependency JAR file

Open the official homepage of the SLF4J website and go to the download page.

SLF4J Homepage

Now, download the latest stable version of slf4j-X.X.tar.gz or, according to your operating system (if windows .zip file or if Linux tar.gz file).

Within the downloaded folder, you will find slf4j-api-X.X.jar. This is the required Jar file.

Step 2: Create a project and set build path

Open eclipse and create a sample project. Right-click on the project, select the option Build Path → Configure Build Path… as shown below.

Project And Set Build Path

In the Java Build Path frame in the Libraries tab, click Add External JARs…

Java Build Path

Select the slf4j-api.x.x.jar file downloaded and click Apply and Close.

Apply And Close

SLF4J Bindings

In addition to slf4j-api.x.x.jar file, SLF4J provides several other Jar files as shown below. These are called SLF4J bindings.

SLF4J Bindings

Where each binding is for its respective logging framework.

The following table lists the SLF4J bindings and their corresponding frameworks.

Sr.No Jar file & Logging Framework


No operation, discards all loggings.



Simple implementation where messages for info and higher are printed and, remaining all outputs to System.err.



Jakarta Commons Logging framework.



Java.util.logging framework (JUL).



Log4J frame work. In addition, you need to have log4j.jar.

To make SLF4J work along with slf4l-api-x.x.jar, you need to add the respective Jar file (binding) of the desired logger framework in the classpath of the project (set build path).

To switch from one framework to other, you need to replace the respective binding. If no bounding is found, it defaults to no-operation mode.

Pom.xml for SLF4J

If you are creating the maven project, open the pom.xml and paste the following content in it and refresh the project.

<project xmlns = ""
   xmlns:xsi = ""
   xsi:schemaLocation = "">