Hackerss.com

hackerss
hackerss

Posted on

How to use logback logger in Java

How to use logback logger - Java:


package com.javadoc;

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

/**
 * This class is used to show how to use logback logger with javadoc.
 * @author javadoc
 * @version 1.0
 * @since 1.8
 */
public class LogbackExample {

    /**
     * This method is used to show how to use logback logger with javadoc.
     * @param args Unused.
     * @return Nothing.
     * @exception IOException On input error.
     * @see IOException
     */
    public static void main(String[] args) throws IOException {

        //Create a logger instance with the name of the class
        final Logger logger = LoggerFactory.getLogger(LogbackExample.class);

        //Log a message at the INFO level.
        logger.info("This is an info message");

        //Log a message at the DEBUG level.
        logger.debug("This is a debug message");

        //Log a message at the WARN level.
        logger.warn("This is a warn message");

        //Log a message at the ERROR level.
        logger.error("This is an error message");

    }
}

Enter fullscreen mode Exit fullscreen mode

Top comments (0)