Hackerss.com

hackerss
hackerss

Posted on

Example use of slf4j in Java

Example use of slf4j - Java:

package com.javacodegeeks.examples.logback;

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

/**
* This class is an example of how to use slf4j with javadoc.
* @author javacodegeeks.com
*/
public class ExampleSlf4j {
   /**
   * This method is an example of how to use slf4j with javadoc.
   * @param args String[]
   */   
   public static void main(String[] args) {
       //Create a logger instance with the name of the class
       Logger logger = LoggerFactory.getLogger(ExampleSlf4j.class);
       //Log a message with the info level
       logger.info("This is an info message");
       //Log a message with the debug level
       logger.debug("This is a debug message");
       //Log a message with the error level
       logger.error("This is an error message");
   }
}

Enter fullscreen mode Exit fullscreen mode

Top comments (0)