Skip to content

Commit

Permalink
Use local LoggerContext in Log4jLog when static field not initialized…
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoeller committed Jan 28, 2020
1 parent d93403a commit 8cced42
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -157,7 +157,12 @@ private static class Log4jLog implements Log, Serializable {
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
Expand Down

0 comments on commit 8cced42

Please sign in to comment.