All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.yedaxia.apidocs.LogUtils Maven / Gradle / Ivy

There is a newer version: 1.4.4
Show newest version
package io.github.yedaxia.apidocs;

import java.io.IOException;
import java.util.logging.*;

/**
 * a simple logger
 *
 * @author yeguozhong yedaxia.github.com
 */
public class LogUtils {

    private static final Logger LOGGER = Logger.getGlobal();

    static{
        try{
            FileHandler fileHandler = new FileHandler(DocContext.getLogFile().getAbsolutePath());
            fileHandler.setFormatter(new SimpleFormatter());
            fileHandler.setLevel(Level.ALL);
            LOGGER.addHandler(fileHandler);
        }catch (IOException e){
            e.printStackTrace();
        }
    }

    public static void info(String message, Object... args){
        LOGGER.info(String.format(message, args));
    }

    public static void warn(String message, Object... args){
        LOGGER.warning(String.format(message, args));
    }

    public static void error(String message, Object... args){
        LOGGER.severe(String.format(message, args));
    }

    public static void error(String message, Throwable e){
        LOGGER.log(Level.SEVERE, message, e);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy