From f6d433de00eee22b0a6bde259f17f9f5435811d9 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Thu, 13 Jan 2022 12:53:49 +0100 Subject: [PATCH] Fixed bug in error nginx time parsing. --- .../metrics/http/HttpErrorLogAnalyzer.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/fr/devinsy/statoolinfos/metrics/http/HttpErrorLogAnalyzer.java b/src/fr/devinsy/statoolinfos/metrics/http/HttpErrorLogAnalyzer.java index c5e95f0..c845f25 100644 --- a/src/fr/devinsy/statoolinfos/metrics/http/HttpErrorLogAnalyzer.java +++ b/src/fr/devinsy/statoolinfos/metrics/http/HttpErrorLogAnalyzer.java @@ -84,6 +84,8 @@ public class HttpErrorLogAnalyzer { if ((file != null) && (!file.isFile()) || (file.exists())) { + System.out.println("Probing file [" + file.getAbsolutePath() + "]"); + // Pattern pattern; if (LineIterator.readFirstLine(file).startsWith("[")) @@ -167,7 +169,14 @@ public class HttpErrorLogAnalyzer if (matcher.matches()) { result = new HttpErrorLog(); - result.setTime(LocalDateTime.parse(matcher.group("time"), DateTimeFormatter.ofPattern("EEE MMM dd HH:mm:ss.SSSSSS yyyy").withLocale(Locale.ENGLISH))); + if (pattern == APACHE_ERROR_PATTERN) + { + result.setTime(LocalDateTime.parse(matcher.group("time"), DateTimeFormatter.ofPattern("EEE MMM dd HH:mm:ss.SSSSSS yyyy").withLocale(Locale.ENGLISH))); + } + else if (pattern == NGINX_ERROR_PATTERN) + { + result.setTime(LocalDateTime.parse(matcher.group("time"), DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss").withLocale(Locale.ENGLISH))); + } result.setLevel(matcher.group("level")); } else