Added sample log entry to visualize log formatting

This commit is contained in:
delvh 2020-06-13 16:57:42 +02:00
parent c72bd60b45
commit 9123e32e49

View File

@ -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);