mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 19:15:32 +01:00
Make all new loggers default to the same logging as "Minecraft" (to console + file, same format)
This commit is contained in:
parent
264b5c331d
commit
a59149c208
42
src/main/java/net/minecraft/server/ConsoleLogManager.java
Normal file
42
src/main/java/net/minecraft/server/ConsoleLogManager.java
Normal file
@ -0,0 +1,42 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import java.util.logging.ConsoleHandler;
|
||||
import java.util.logging.FileHandler;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class ConsoleLogManager {
|
||||
|
||||
public static Logger a = Logger.getLogger("Minecraft");
|
||||
public static Logger global = Logger.getLogger(""); // Craftbukkit
|
||||
|
||||
public ConsoleLogManager() {}
|
||||
|
||||
public static void a() {
|
||||
ConsoleLogFormatter consolelogformatter = new ConsoleLogFormatter();
|
||||
|
||||
a.setUseParentHandlers(false);
|
||||
ConsoleHandler consolehandler = new ConsoleHandler();
|
||||
|
||||
// Craftbukkit start
|
||||
for (Handler handler : global.getHandlers()) {
|
||||
global.removeHandler(handler);
|
||||
}
|
||||
// Craftbukkit end
|
||||
|
||||
consolehandler.setFormatter(consolelogformatter);
|
||||
a.addHandler(consolehandler);
|
||||
global.addHandler(consolehandler); // Craftbukkit
|
||||
|
||||
try {
|
||||
FileHandler filehandler = new FileHandler("server.log", true);
|
||||
|
||||
filehandler.setFormatter(consolelogformatter);
|
||||
a.addHandler(filehandler);
|
||||
global.addHandler(filehandler); // Craftbukkit
|
||||
} catch (Exception exception) {
|
||||
a.log(Level.WARNING, "Failed to log to server.log", exception);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user