com.zusmart.basic.logging.support.JdkLoggerFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zusmart-basic Show documentation
Show all versions of zusmart-basic Show documentation
基础模块,提供配置,日志,SPI,图排序,路径匹配,资源扫描,包扫描,常用工具类
package com.zusmart.basic.logging.support;
import java.io.ByteArrayInputStream;
import java.util.logging.LogManager;
import com.zusmart.basic.logging.Logger;
import com.zusmart.basic.logging.LoggerFactory;
public class JdkLoggerFactory extends LoggerFactory {
public JdkLoggerFactory(){
try{
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(".level").append("=").append("FINEST").append("\n");
stringBuffer.append("java.level").append("=").append("INFO").append("\n");
stringBuffer.append("javax.level").append("=").append("INFO").append("\n");
stringBuffer.append("com.sun.level").append("=").append("INFO").append("\n");
stringBuffer.append("sun.level").append("=").append("INFO").append("\n");
stringBuffer.append("jdk.level").append("=").append("INFO").append("\n");
stringBuffer.append("handlers").append("=").append("java.util.logging.ConsoleHandler").append("\n");
stringBuffer.append("java.util.logging.ConsoleHandler.level").append("=").append("FINEST").append("\n");
stringBuffer.append("java.util.logging.ConsoleHandler.formatter").append("=").append("com.zusmart.basic.logging.support.JdkLoggerFormater").append("\n");
ByteArrayInputStream inputStream = new ByteArrayInputStream(stringBuffer.toString().getBytes("UTF-8"));
LogManager logManager = LogManager.getLogManager();
logManager.readConfiguration(inputStream);
inputStream.close();
}catch(Exception e){
e.printStackTrace();
}
}
@Override
protected Logger newInstance(String name) {
return new JdkLogger(java.util.logging.Logger.getLogger(name));
}
}