Merge pull request #25 from informatik-ag-ngl/f/throwable_in_log

Include throwable in log records
This commit is contained in:
Kai S. K. Engelbart 2020-06-25 08:01:45 +00:00 committed by GitHub
commit d03d51e65e

View File

@ -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.<br>
* <br>
* console and a log file.
* <p>
* Call the {@link EnvoyLog#attach(String)} method to configure a part of the
* logger hierarchy.<br>
* <br>
* logger hierarchy.
* <p>
* Project: <strong>envoy-client</strong><br>
* File: <strong>EnvoyLogger.java</strong><br>
* Created: <strong>14 Dec 2019</strong><br>
@ -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 {