⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 logmanager.java

📁 自己编写的一个JSP+SERVER的框架, 实际项目已经运用多次,效率很好.
💻 JAVA
字号:
/**
* Creation date: 08-16-2005
* @author QingHe
*
*/

package com.aptech.util;

import java.net.URL;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;


public class LogManager {
	private static Object lock = new Object();
	private static String LOG_CONF_FILEA = "/com/aptech/util/log4j.properties";
	/**
	 * default logger
	 */
	
	public static final String DEFAULT = "default";
	
	public static final String CUSTOMERINFO = "customerinfo";
	public static final String CUSTOMERERR = "customererr";	
	
	public static final String BUSINESSINFO = "businessinfo";
	public static final String BUSINESSERR = "businesserr";
	
	private static LogManager instance = null;
	
	private Logger logger = null;	
	
	private Logger customerLogger = null;
	private Logger customerErrLogger = null;	
	
	private Logger businessLogger = null;
	private Logger businessErrLogger = null;
	
	
	/**
	 * @author QingHe
	 * ˽�й��캯�� Ӧ�õ���ģʽ
	 */
	private LogManager() {
		URL res = this.getClass().getResource(LOG_CONF_FILEA);
		if (res != null) {
			PropertyConfigurator.configure(res);
			logger = Logger.getLogger(DEFAULT);
			
			customerLogger = Logger.getLogger(CUSTOMERINFO);			
			customerErrLogger = Logger.getLogger(CUSTOMERERR);
			
			businessLogger = Logger.getLogger(BUSINESSINFO);	
			businessErrLogger = Logger.getLogger(BUSINESSERR);	
		}
		else {
			logger.error(
				new StringBuffer(
					"Can't find the log configuration file:").append(
							LOG_CONF_FILEA));
		}
	}


	/**
	 * @author QingHe
	 * @param argv[]
	 * ������
	 */
	public static void main(String argv[]) {

		LogManager.getInstance().getCustomerLogger().debug("This is customer");
		
		LogManager.getInstance().getBusinessErrLogger().error("This is business error");
		
	}
	
	/**
	 * @author QingHe
	 * @return com.creawor.vipus.util.LogManager
	 * ����ģʽ �������ʵ��
	 */
	public static LogManager getInstance() {
		if (instance == null) {
			synchronized (lock) {
				if (instance == null) {
					instance = new LogManager();
				}
			}
		}
		return instance;
	}
	
	/**
	 * 
	 * @return org.apache.log4j.Logger;
	 */
	public Logger getDefaultLogger() {
		return this.logger;
	}


	/**
	 * @return Returns the businessErrLogger.
	 */
	public Logger getBusinessErrLogger() {
		return businessErrLogger;
	} 
 

	/**
	 * @return Returns the businessLogger.
	 */
	public Logger getBusinessLogger() {
		return businessLogger;
	}


	/**
	 * @return Returns the customerErrLogger.
	 */
	public Logger getCustomerErrLogger() {
		return customerErrLogger;
	}


	/**
	 * @return Returns the customerLogger.
	 */
	public Logger getCustomerLogger() {
		return customerLogger;
	}
	
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -