@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:/spring/application.xml")
public class MainTest {
Logger XJK_USER_LOG = LoggerUtils.Logger(LogFileName.XJK_USER);
Logger BAITIAO_USER_LOG = LoggerUtils.Logger(LogFileName.BAITIAO_USER);
@Test
public void testGetBusinessAccount() throws Exception {
XJK_USER_LOG.info("小金库用户进来了...");
BAITIAO_USER_LOG.info("白条用户进来了...");
}
}
public enum LogFileName {
//配置到logback.xml中的logger name="vipUser"
XJK_USER("xjkUser"),
BAITIAO_USER("baitiaoUser");
private String logFileName;
LogFileName(String fileName) {
this.logFileName = fileName;
}
public String getLogFileName() {
return logFileName;
}
public void setLogFileName(String logFileName) {
this.logFileName = logFileName;
}
public static LogFileName getAwardTypeEnum(String value) {
LogFileName[] arr = values();
for (LogFileName item : arr) {
if (null != item && StringUtils.isNotBlank(item.logFileName)) {
return item;
}
}
return null;
}
}
public class LoggerUtils {
public static
return LoggerFactory.getLogger(clazz);
}
/**
* 打印到指定的文件下
*
* @param desc 日志文件名称
* @return
*/
public static Logger Logger(LogFileName desc) {
return LoggerFactory.getLogger(desc.getLogFileName());
}
}
---------------------
作者:jd_guojiangjiang
来源:CSDN
原文:https://blog.csdn.net/mggwct/article/details/77718122
版权声明:本文为博主原创文章,转载请附上博文链接!