Browse Source

Use local LoggerContext in Log4jLog when static field not initialized yet

Closes gh-24440
pull/24460/head
Juergen Hoeller 5 years ago
parent
commit
8cced42fb2
  1. 9
      spring-jcl/src/main/java/org/apache/commons/logging/LogAdapter.java

9
spring-jcl/src/main/java/org/apache/commons/logging/LogAdapter.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -157,7 +157,12 @@ final class LogAdapter { @@ -157,7 +157,12 @@ final class LogAdapter {
private final ExtendedLogger logger;
public Log4jLog(String name) {
this.logger = loggerContext.getLogger(name);
LoggerContext context = loggerContext;
if (context == null) {
// Circular call in early-init scenario -> static field not initialized yet
context = LogManager.getContext(Log4jLog.class.getClassLoader(), false);
}
this.logger = context.getLogger(name);
}
@Override

Loading…
Cancel
Save