package org.fouram.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.fouram.core.util.ConfConfig;
import org.fouram.core.util.DateUtil;
import org.fouram.core.util.LoggerUtil;

/**
 * 加载系统配置文件
 * 
 * @author liup
 * 
 */
public class SystemInitListener implements ServletContextListener {

	@Override
	public void contextDestroyed(ServletContextEvent arg0) {
		LoggerUtil.info("容器关闭……");
	}

	@Override
	public void contextInitialized(ServletContextEvent config) {
		try {
			// 开启log4j2全异步模式
			System.setProperty("Log4jContextSelector", "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector");
			LoggerUtil.info("ENV:" + ConfConfig.getConfigString("env"));
			LoggerUtil.info("当前时间:" + DateUtil.getTime());
		} catch (Exception e) {
			LoggerUtil.error(e);
		}
	}
}