Fixed bug in error nginx time parsing.

This commit is contained in:
Christian P. MOMON 2022-01-13 12:53:49 +01:00
parent 79441007b0
commit f6d433de00

View file

@ -84,6 +84,8 @@ public class HttpErrorLogAnalyzer
{ {
if ((file != null) && (!file.isFile()) || (file.exists())) if ((file != null) && (!file.isFile()) || (file.exists()))
{ {
System.out.println("Probing file [" + file.getAbsolutePath() + "]");
// //
Pattern pattern; Pattern pattern;
if (LineIterator.readFirstLine(file).startsWith("[")) if (LineIterator.readFirstLine(file).startsWith("["))
@ -167,7 +169,14 @@ public class HttpErrorLogAnalyzer
if (matcher.matches()) if (matcher.matches())
{ {
result = new HttpErrorLog(); result = new HttpErrorLog();
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))); 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")); result.setLevel(matcher.group("level"));
} }
else else