mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 10:54:51 +00:00
Added a quick function to disable logs
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
package org.toop;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.core.LoggerContext;
|
||||
import org.apache.logging.log4j.core.config.Configuration;
|
||||
import org.apache.logging.log4j.core.config.LoggerConfig;
|
||||
import org.toop.eventbus.EventRegistry;
|
||||
import org.toop.eventbus.Events;
|
||||
import org.toop.eventbus.GlobalEventBus;
|
||||
import org.toop.server.backend.ServerManager;
|
||||
@@ -21,6 +26,7 @@ public class Main {
|
||||
|
||||
public static void main(String[] args) throws ExecutionException, InterruptedException {
|
||||
initSystems();
|
||||
disableLogs();
|
||||
|
||||
ConsoleGui console = new ConsoleGui();
|
||||
|
||||
@@ -35,4 +41,21 @@ public class Main {
|
||||
new ServerManager();
|
||||
new ConnectionManager();
|
||||
}
|
||||
|
||||
public static void disableLogs() {
|
||||
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
|
||||
Configuration config = ctx.getConfiguration();
|
||||
LoggerConfig loggerConfig = config.getLoggerConfig(EventRegistry.class.getName());
|
||||
loggerConfig.setLevel(Level.OFF);
|
||||
ctx.updateLoggers(); // apply changes immediately
|
||||
}
|
||||
|
||||
public static void enableLogs(Level level) {
|
||||
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
|
||||
Configuration config = ctx.getConfiguration();
|
||||
LoggerConfig loggerConfig = config.getLoggerConfig(EventRegistry.class.getName());
|
||||
loggerConfig.setLevel(level);
|
||||
ctx.updateLoggers();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user