调整日志收集的参数

This commit is contained in:
zlzw 2022-11-12 16:56:02 +08:00
parent 059bfaf1d9
commit 8455c360fc

View File

@ -42,8 +42,8 @@ public class LogUtils {
File dir = new File(context.getDir("files", Context.MODE_PRIVATE).getAbsolutePath() + File.separator); File dir = new File(context.getDir("files", Context.MODE_PRIVATE).getAbsolutePath() + File.separator);
if (dir.listFiles() != null) { if (dir.listFiles() != null) {
for (File file : dir.listFiles()) { for (File file : dir.listFiles()) {
if (!file.getName().endsWith(".log") && !"error.log".equals(file.getName())) { if (file.getName().endsWith(".log") && !"error.log".equals(file.getName())) {
String fileName = file.getName().replace(title, ""); String fileName = file.getName().replace(title, "").replace(".log", "");
if (isDelLog(fileName)) { if (isDelLog(fileName)) {
file.delete(); file.delete();
} }
@ -51,7 +51,7 @@ public class LogUtils {
} }
} }
File saveFile = new File(context.getDir("files", Context.MODE_PRIVATE).getAbsolutePath() + File.separator + today + ".log"); File saveFile = new File(context.getDir("files", Context.MODE_PRIVATE).getAbsolutePath() + File.separator + today + ".log");
FileOutputStream os = new FileOutputStream(saveFile,true); FileOutputStream os = new FileOutputStream(saveFile, true);
writer = new PrintWriter(os); writer = new PrintWriter(os);
while ((line = bufferedReader.readLine()) != null) { while ((line = bufferedReader.readLine()) != null) {
writer.append(line).write("\n"); writer.append(line).write("\n");