From e0cd44083f07a44b8a85df348e31cc6b38393eb6 Mon Sep 17 00:00:00 2001 From: CyB3RC0nN0R Date: Thu, 25 Jun 2020 08:01:34 +0200 Subject: [PATCH] Include throwable in log records --- src/main/java/envoy/util/EnvoyLog.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main/java/envoy/util/EnvoyLog.java b/src/main/java/envoy/util/EnvoyLog.java index 1e5193c..d64e69f 100644 --- a/src/main/java/envoy/util/EnvoyLog.java +++ b/src/main/java/envoy/util/EnvoyLog.java @@ -2,19 +2,19 @@ package envoy.util; import java.io.File; import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.Date; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.logging.*; import envoy.data.Config; /** * Configures the {@link java.util.logging} API to output the log into the - * console and a log file.
- *
+ * console and a log file. + *

* Call the {@link EnvoyLog#attach(String)} method to configure a part of the - * logger hierarchy.
- *
+ * logger hierarchy. + *

* Project: envoy-client
* File: EnvoyLogger.java
* Created: 14 Dec 2019
@@ -46,13 +46,12 @@ public class EnvoyLog { // Configure log file final File logFile = new File((File) config.get("homeDirectory").get(), - "log/envoy_user_" + new SimpleDateFormat("yyyy-MM-dd--hh-mm-mm").format(new Date()) + ".log"); + "log/envoy_user_" + DateTimeFormatter.ofPattern("yyyy-MM-dd--hh-mm-mm").format(LocalDateTime.now()) + ".log"); logFile.getParentFile().mkdirs(); // Configure formatting - // Sample log entry: [2020-06-13 16:50:26] [INFORMATION] - // [envoy.client.ui.Startup] Closing connection... - System.setProperty("java.util.logging.SimpleFormatter.format", "[%1$tF %1$tT] [%4$-7s] [%3$s] %5$s %n"); + // Sample log entry: [2020-06-13 16:50:26] [INFORMATION] [envoy.client.ui.Startup] Closing connection... + System.setProperty("java.util.logging.SimpleFormatter.format", "[%1$tF %1$tT] [%4$-7s] [%3$s] %5$s %6$s%n"); final SimpleFormatter formatter = new SimpleFormatter(); try {