aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2024-11-24 19:52:24 +0000
committerPJ Fanning <fanningpj@apache.org>2024-11-24 19:52:24 +0000
commita2af56511f07736ed73a3812c9eb1adf892077ca (patch)
tree3d87e5048556aa8d636a034967b119fb1f73e5cb
parent924d8e78940d2941788e70c9863ddb9d57b7146d (diff)
downloadpoi-a2af56511f07736ed73a3812c9eb1adf892077ca.tar.gz
poi-a2af56511f07736ed73a3812c9eb1adf892077ca.zip
PoiLogManager
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1922056 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--poi/src/main/java/org/apache/poi/logging/PoiLogManager.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/poi/src/main/java/org/apache/poi/logging/PoiLogManager.java b/poi/src/main/java/org/apache/poi/logging/PoiLogManager.java
index 78ec997cc5..a6289fc08a 100644
--- a/poi/src/main/java/org/apache/poi/logging/PoiLogManager.java
+++ b/poi/src/main/java/org/apache/poi/logging/PoiLogManager.java
@@ -56,6 +56,27 @@ public final class PoiLogManager {
}
}
+ public static Logger getLogger(String name) {
+ try {
+ final Logger logger = LogManager.getLogger(name);
+ if (logger == null) {
+ if (shouldLog()) {
+ System.err.println("[PoiLogManager] Log4J returned null logger. Falling back to No-Op logger.");
+ }
+ return NoOpLogger.INSTANCE;
+ }
+ return logger;
+ } catch (Throwable t) {
+ if (!ExceptionUtil.isFatal(t)) {
+ if (shouldLog()) {
+ System.err.println("[PoiLogManager] Issue loading Log4J. Falling back to No-Op logger.");
+ t.printStackTrace();
+ }
+ }
+ return NoOpLogger.INSTANCE;
+ }
+ }
+
private static synchronized boolean shouldLog() {
final long time = System.currentTimeMillis();
if (time > LAST_TIME + SLEEP_TIME) {