mirror of https://github.com/apache/poi.git
PoiLogManager
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1922056 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
924d8e7894
commit
a2af56511f
|
@ -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() {
|
private static synchronized boolean shouldLog() {
|
||||||
final long time = System.currentTimeMillis();
|
final long time = System.currentTimeMillis();
|
||||||
if (time > LAST_TIME + SLEEP_TIME) {
|
if (time > LAST_TIME + SLEEP_TIME) {
|
||||||
|
|
Loading…
Reference in New Issue