Skip to content

Commit

Permalink
XmlBeansLogManager handle null logger case
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/xmlbeans/trunk@1921989 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
pjfanning committed Nov 21, 2024
1 parent 5eacf3e commit 31f92ec
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,19 @@ private XmlBeansLogManager() {
}

public static Logger getLogger(Class<?> clz) {
final long time = System.currentTimeMillis();
try {
return LogManager.getLogger(clz);
final Logger logger = LogManager.getLogger(clz);
if (logger == null) {
if (time > LAST_TIME + SLEEP_TIME) {
LAST_TIME = time;
System.err.println("Log4J returned null logger. Falling back to No-Op logger.");
}
return NoOpLogger.INSTANCE;
}
return logger;
} catch (Throwable t) {
if (!ExceptionUtil.isFatal(t)) {
final long time = System.currentTimeMillis();
if (time > LAST_TIME + SLEEP_TIME) {
LAST_TIME = time;
System.err.println("Issue loading Log4J. Falling back to No-Op logger.");
Expand Down

0 comments on commit 31f92ec

Please sign in to comment.