/**
 * Copyright 2008-2009. Chongqing Communications Industry Services Co.,Ltd Information Technology Branch. All rights reserved.
 * <a>http://www.crunii.com</a>
 */
package com.crunii.micro.common.utils;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
import org.slf4j.LoggerFactory;

import java.util.List;

/**
 * @author 田平 create 2023-02-21 11:49:20
 */
public class LogbackUtil {
	/**
	 * <pre>
	 *     可以在main方法测试的时候设置日志级别，
	 *     不然默认为debug级别，不方便调试
	 * </pre>
	 *
	 * @param logLevel
	 */
	public static void setLogLevel(String logLevel) {
		LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
		List<Logger> loggerList = loggerContext.getLoggerList();
		loggerList.forEach(logger -> {
			logger.setLevel(Level.toLevel(logLevel));
		});
	}
}
