From a17f5e826f42e55c3f6d10213867eff53002ec2d Mon Sep 17 00:00:00 2001 From: tueem Date: Thu, 19 Dec 2024 12:28:45 +0100 Subject: [PATCH] add LoggerUtil to decide which Logger to get --- .../tomatentum/marinara/util/LoggerUtil.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 lib/src/main/java/net/tomatentum/marinara/util/LoggerUtil.java diff --git a/lib/src/main/java/net/tomatentum/marinara/util/LoggerUtil.java b/lib/src/main/java/net/tomatentum/marinara/util/LoggerUtil.java new file mode 100644 index 0000000..99c57cd --- /dev/null +++ b/lib/src/main/java/net/tomatentum/marinara/util/LoggerUtil.java @@ -0,0 +1,20 @@ +package net.tomatentum.marinara.util; + +import java.util.Properties; + +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.simple.SimpleLogger; +import org.apache.logging.log4j.util.PropertiesUtil; +import org.apache.logging.log4j.util.ProviderUtil; + +public class LoggerUtil { + public static Logger getLogger(String name) { + if (ProviderUtil.hasProviders()) { + return LogManager.getLogger(name); + }else + return new SimpleLogger(name, Level.DEBUG, true, false, true, true, "yyyy-MM-dd HH:mm:ss.SSSZ", null, + new PropertiesUtil(new Properties()), System.out); + } +}