com.fastchar.slf4j.core.FastLog4jLogger Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fastchar-slf4j Show documentation
Show all versions of fastchar-slf4j Show documentation
FastChar-SLF4J is a FastChar plugin.
The newest version!
package com.fastchar.slf4j.core;
import java.util.LinkedHashMap;
import java.util.Map;
public class FastLog4jLogger {
private String name;
private boolean additivity;
private final Map rollingFiles = new LinkedHashMap<>();
public String getName() {
return name;
}
/**
* 需要分割的名匹配,一般是类的完整名,例如:com.fastchar.core.FastActionLogger
*
* @param name 字符串
* @return 当前对象
*/
public FastLog4jLogger setName(String name) {
this.name = name;
return this;
}
/**
* 添加日志级别分割文件
*
* @param rollingFiles 配置信息
* @return 当前对象
*/
public FastLog4jLogger addRollingFile(FastLog4jRollingFile... rollingFiles) {
for (FastLog4jRollingFile rollingFile : rollingFiles) {
this.rollingFiles.put(rollingFile.getLevel(), rollingFile);
}
return this;
}
/**
* 添加日志级别分割文件
*
* @param fileName 生成的日志文件名
* @param levels 日志级别
* @return 当前对象
*/
public FastLog4jLogger addRollingFile(String fileName,boolean console, FastLog4jLevelEnum... levels) {
for (FastLog4jLevelEnum level : levels) {
this.rollingFiles.put(level, new FastLog4jRollingFile().setConsole(console).setFileName(fileName).setLevel(level));
}
return this;
}
public Map getRollingFiles() {
return rollingFiles;
}
public boolean isAdditivity() {
return additivity;
}
public FastLog4jLogger setAdditivity(boolean additivity) {
this.additivity = additivity;
return this;
}
public FastLog4jLevelEnum getLevel() {
FastLog4jLevelEnum minLevel = FastLog4jLevelEnum.OFF;
for (Map.Entry entry : this.rollingFiles.entrySet()) {
if (entry.getKey().ordinal() < minLevel.ordinal()) {
minLevel = entry.getKey();
}
}
return minLevel;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy