服务器日志地址


try {
Date now = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
String logName = sdf.format(now);
//服务器日志地址 /data/website/zhuohuiclass/cloud/logs/
File logFile = new File("E:\\foen_api\\foen_api_log\\logs\\", logName+".txt");
if (!logFile.exists()) {
//logFile.mkdirs();
logFile.createNewFile();
}
if(StringUtils.isBlank("")){

}
//数据分析用 用户编号 IP 方法 时间
String data =userName+"\t"+ip+"\t"+remark+"\t"+responseTime+"\t"+"\r\n";
FileOutputStream out = new FileOutputStream(logFile,true);
out.write(data.getBytes());
out.close();
}catch (Exception e){
logger.error("==> 日志异常");
}
posted @ 2019-11-08 15:12  A汉克先生  阅读(273)  评论(0编辑  收藏  举报