diff --git a/build.gradle b/build.gradle index 39e3cde..f435410 100644 --- a/build.gradle +++ b/build.gradle @@ -34,8 +34,8 @@ dependencies { Since these are `implementation` dependencies, they are packed in the final jar. Read the documentation at https://docs.gradle.org/current/userguide/declaring_dependencies.html to learn more */ - //implementation 'org.apache.logging.log4j:log4j-api:2.+' - //implementation 'org.apache.logging.log4j:log4j-core:2.+' + implementation 'org.apache.logging.log4j:log4j-api:2.+' + implementation 'org.apache.logging.log4j:log4j-core:2.+' /* This is another example - it imports the javafx-controls dependency diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/ log4j2.tld b/src/main/java/ch/unibas/dmi/dbis/cs108/ log4j2.tld new file mode 100644 index 0000000..1e7cece --- /dev/null +++ b/src/main/java/ch/unibas/dmi/dbis/cs108/ log4j2.tld @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/BudaLogConfig.java b/src/main/java/ch/unibas/dmi/dbis/cs108/BudaLogConfig.java new file mode 100644 index 0000000..7552a50 --- /dev/null +++ b/src/main/java/ch/unibas/dmi/dbis/cs108/BudaLogConfig.java @@ -0,0 +1,23 @@ +package ch.unibas.dmi.dbis.cs108; + +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.core.LoggerContext; +import org.apache.logging.log4j.core.config.Configuration; +import org.apache.logging.log4j.core.config.LoggerConfig; + +public class BudaLogConfig { + + public Logger LOGGER; + + public BudaLogConfig(Logger LOGGER) { + this.LOGGER = LOGGER; + LoggerContext ctx = (LoggerContext) LogManager.getContext(false); + Configuration config = ctx.getConfiguration(); + LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME); + loggerConfig.setLevel(Level.INFO); // change level here + ctx.updateLoggers(); // This causes all Loggers to refetch information from their LoggerConfig. + } + +}