package org.aohe.utils;

import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.core.FileAppender;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;

public class LogUtil {
    public static String getLogPath() throws IOException {
        LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
        ch.qos.logback.classic.Logger logger = context.getLogger("ROOT");
        FileAppender fileAppender = (FileAppender) logger.getAppender("file");//"file"是 logback 配置中，输出日志文件的 appender 的 name 属性
        File file = new File(fileAppender.getFile());
        return file.getCanonicalPath();
    }
}
