Added sample log entry to visualize log formatting
This commit is contained in:
parent
c72bd60b45
commit
9123e32e49
@ -45,13 +45,15 @@ public class EnvoyLog {
|
|||||||
LogManager.getLogManager().reset();
|
LogManager.getLogManager().reset();
|
||||||
|
|
||||||
// Configure log file
|
// 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");
|
"log/envoy_user_" + new SimpleDateFormat("yyyy-MM-dd--hh-mm-mm").format(new Date()) + ".log");
|
||||||
logFile.getParentFile().mkdirs();
|
logFile.getParentFile().mkdirs();
|
||||||
|
|
||||||
// Configure formatting
|
// 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");
|
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 {
|
try {
|
||||||
fileHandler = new FileHandler(logFile.getAbsolutePath());
|
fileHandler = new FileHandler(logFile.getAbsolutePath());
|
||||||
@ -85,7 +87,7 @@ public class EnvoyLog {
|
|||||||
if (!initialized) throw new IllegalStateException("EnvoyLog is not initialized");
|
if (!initialized) throw new IllegalStateException("EnvoyLog is not initialized");
|
||||||
|
|
||||||
// Get root logger
|
// Get root logger
|
||||||
Logger logger = Logger.getLogger(path);
|
final Logger logger = Logger.getLogger(path);
|
||||||
|
|
||||||
// Add handlers
|
// Add handlers
|
||||||
if (fileHandler != null) logger.addHandler(fileHandler);
|
if (fileHandler != null) logger.addHandler(fileHandler);
|
||||||
|
Reference in New Issue
Block a user