(个人笔记) java.util.logging.Logger 写日志

来源:互联网 发布:培育发展新动力优化 编辑:程序博客网 时间:2024/05/18 17:01

向日志写入文件


    public static Logger getLogger(String className){        Logger logger = Logger.getLogger(className);        String logPath = "log/log.log";   //要写相对路径        try {            FileHandler fh = new FileHandler(logPath);            logger.addHandler(fh);        } catch (IOException ex) {            Logger.getLogger(Util.class.getName()).log(Level.SEVERE, null, ex);        } catch (SecurityException ex) {            Logger.getLogger(Util.class.getName()).log(Level.SEVERE, null, ex);        }        return logger;    }


原创粉丝点击