My new website on Artificial Intelligence and Machine Learning

SLF4J binding with Logback

The logback logger implementation is a super quality implementation. If you intend to write serious code that go into production, you may want to evaluate this option..

package com.javavillage.slf4j;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class SLF4JSample {

	private static Logger LOGGER = LoggerFactory.getLogger(SLF4JSample.class);
    public static void main(String[] args) {"Hi, Welcome to SLF4J exmaple");

for now I am adding below dependency for maven pom.xml
Here is a sample of configuration src/main/resources/logback.xml to get things started.
  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
      <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>

  <logger name="javavillage" level="DEBUG"/>

  <root level="INFO">
    <appender-ref ref="STDOUT" />
project structure after maven build.

SLF4J with JDK14 workspace

Now you see logging output on STDOUT with INFO level..

16:26:05.079 [main] INFO  com.javavillage.slf4j.SLF4JSample - Hi, Welcome to SLF4J exmaple