From 9123e32e49b8fb94237c077f66ffec5ab8d0d9db Mon Sep 17 00:00:00 2001 From: delvh Date: Sat, 13 Jun 2020 16:57:42 +0200 Subject: [PATCH] Added sample log entry to visualize log formatting --- src/main/java/envoy/util/EnvoyLog.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/envoy/util/EnvoyLog.java b/src/main/java/envoy/util/EnvoyLog.java index f3bc919..1e5193c 100644 --- a/src/main/java/envoy/util/EnvoyLog.java +++ b/src/main/java/envoy/util/EnvoyLog.java @@ -45,13 +45,15 @@ public class EnvoyLog { LogManager.getLogManager().reset(); // Configure log file - File logFile = new File((File) config.get("homeDirectory").get(), + 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"); 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"); - SimpleFormatter formatter = new SimpleFormatter(); + final SimpleFormatter formatter = new SimpleFormatter(); try { fileHandler = new FileHandler(logFile.getAbsolutePath()); @@ -85,7 +87,7 @@ public class EnvoyLog { if (!initialized) throw new IllegalStateException("EnvoyLog is not initialized"); // Get root logger - Logger logger = Logger.getLogger(path); + final Logger logger = Logger.getLogger(path); // Add handlers if (fileHandler != null) logger.addHandler(fileHandler);