1.读取服务器目录下所有日志文件,按行解析内容,查找日志埋点
File dir = new File("/u02/tomcat-7.0.64/8080/logs/wl");
File[] listFiles = dir.listFiles();
for (File file : listFiles) {
String name = file.getName();
boolean contains = name.contains("info.log.");
if (contains) {
logger.info("文件名称:{}", name);
FileReader fr = new FileReader(file);
BufferedReader br = new BufferedReader(fr);
String line = null;
while ((line = br.readLine()) != null) {// 通过readline按行读取
if (StringUtils.isBlank(line.trim())) {
continue;
}
}
}
}