Include throwable in log records

This commit is contained in:
Kai S. K. Engelbart 2020-06-25 08:01:34 +02:00
parent 30c14a7269
commit 9156da4e77

View File

@ -2,19 +2,19 @@ package envoy.util;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.text.SimpleDateFormat; import java.time.LocalDateTime;
import java.util.Date; import java.time.format.DateTimeFormatter;
import java.util.logging.*; import java.util.logging.*;
import envoy.data.Config; import envoy.data.Config;
/** /**
* Configures the {@link java.util.logging} API to output the log into the * Configures the {@link java.util.logging} API to output the log into the
* console and a log file.<br> * console and a log file.
* <br> * <p>
* Call the {@link EnvoyLog#attach(String)} method to configure a part of the * Call the {@link EnvoyLog#attach(String)} method to configure a part of the
* logger hierarchy.<br> * logger hierarchy.
* <br> * <p>
* Project: <strong>envoy-client</strong><br> * Project: <strong>envoy-client</strong><br>
* File: <strong>EnvoyLogger.java</strong><br> * File: <strong>EnvoyLogger.java</strong><br>
* Created: <strong>14 Dec 2019</strong><br> * Created: <strong>14 Dec 2019</strong><br>
@ -46,13 +46,12 @@ public class EnvoyLog {
// Configure log file // Configure log file
final 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"); "log/envoy_user_" + DateTimeFormatter.ofPattern("yyyy-MM-dd--hh-mm-mm").format(LocalDateTime.now()) + ".log");
logFile.getParentFile().mkdirs(); logFile.getParentFile().mkdirs();
// Configure formatting // Configure formatting
// Sample log entry: [2020-06-13 16:50:26] [INFORMATION] // Sample log entry: [2020-06-13 16:50:26] [INFORMATION] [envoy.client.ui.Startup] Closing connection...
// [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");
System.setProperty("java.util.logging.SimpleFormatter.format", "[%1$tF %1$tT] [%4$-7s] [%3$s] %5$s %n");
final SimpleFormatter formatter = new SimpleFormatter(); final SimpleFormatter formatter = new SimpleFormatter();
try { try {