/** 设置配置路径从环境变量读取
* PropertyConfigurator类加载.properties文件的配置
* DOMConfigurator加载.xml文件的配置
*/
public class LogInfo {
static {
try {
PropertyConfigurator.configure(new FileInputStream("D:\\code\\first\\Log4JProject\\config\\log4j.properties"));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
private static Logger logger=Logger.getLogger(LogInfo.class);
public static void LogInformation(String info) {
logger.info(info);
logger.debug(info);
logger.error(info);
}
}