All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.zusmart.basic.logging.support.JdkLoggerFactory Maven / Gradle / Ivy

Go to download

基础模块,提供配置,日志,SPI,图排序,路径匹配,资源扫描,包扫描,常用工具类

There is a newer version: 0.0.3
Show newest version
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));
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy