| 1234567891011121314151617181920212223242526272829303132333435 |
- package com.uas.util;
- import java.io.IOException;
- import java.util.Properties;
- import org.apache.log4j.Logger;
- import org.apache.log4j.PropertyConfigurator;
- public class BaseUtil {
- public static Logger logger;
-
- /**
- * 获取日志类
- * @return 日志类
- */
- public static Logger getLogger(){
- if(logger==null){
- logger = Logger.getLogger(BaseUtil.class);
- //loger所需的配置文件路径
- Properties prop = new Properties();
- try {
- prop.load(BaseUtil.class.getResourceAsStream("/properties/log4j.properties"));
- } catch (IOException e) {
- e.printStackTrace();
- }
- PropertyConfigurator.configure(prop);
- }
- return logger;
- }
-
- public static void logDownload(String fileName,String ip,String downloadpath){
- getLogger().info("download " + fileName + " from " + ip + " path:" + downloadpath);
- }
- }
|