You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rg...@apache.org on 2022/09/06 20:13:21 UTC

[logging-log4j2] branch release-2.x updated (7aa9dd8bfa -> 84a0f4e137)

This is an automated email from the ASF dual-hosted git repository.

rgoers pushed a change to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git


    from 7aa9dd8bfa Fix parsing errors on `null` delimiters
     new 53b01c8880 LOG4J2-3588 - Allow a PropertySource to be added
     new 84a0f4e137 LOG4J2-3589 - Allow Plugins to be injected with the LoggerContext reference

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/logging/log4j/util/PropertiesUtil.java  | 21 ++++++++-
 ...mPropertiesPropertySourceSecurityManagerIT.java |  5 ++-
 .../log4j/core/config/AbstractConfiguration.java   |  7 ++-
 ...igurationAware.java => LoggerContextAware.java} | 14 +++---
 .../{PluginNode.java => PluginLoggerContext.java}  |  9 ++--
 ...isitor.java => PluginLoggerContextVisitor.java} | 18 ++++----
 ....java => AbstractLoggerContextAwareLookup.java} | 12 +++---
 .../logging/log4j/core/lookup/Interpolator.java    | 17 +++++++-
 ...tem.java => Log4j2SpringBootLoggingSystem.java} | 16 +++----
 .../log4j/spring/boot/SpringEnvironmentHolder.java | 50 ----------------------
 .../logging/log4j/spring/boot/SpringLookup.java    | 43 +++++++++++--------
 .../log4j/spring/boot/SpringProfileArbiter.java    | 37 +++++++++++++---
 .../log4j/spring/boot/SpringPropertySource.java    | 10 +++--
 .../org.apache.logging.log4j.util.PropertySource   | 15 -------
 .../src/main/resources/META-INF/spring.factories   |  2 +-
 .../spring/boot/Log4j2SpringBootInitTest.java      |  2 +
 ...java => Log4j2SpringBootLoggingSystemTest.java} |  8 ++--
 .../log4j/spring/boot/SpringLookupTest.java        | 10 +++--
 .../log4j/spring/boot/SpringProfileTest.java       |  2 +-
 src/changes/changes.xml                            |  6 +++
 20 files changed, 164 insertions(+), 140 deletions(-)
 copy log4j-core/src/main/java/org/apache/logging/log4j/core/config/{ConfigurationAware.java => LoggerContextAware.java} (72%)
 copy log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/{PluginNode.java => PluginLoggerContext.java} (84%)
 copy log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/{PluginConfigurationVisitor.java => PluginLoggerContextVisitor.java} (71%)
 copy log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/{AbstractConfigurationAwareLookup.java => AbstractLoggerContextAwareLookup.java} (71%)
 rename log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/{Log4j2CloudConfigLoggingSystem.java => Log4j2SpringBootLoggingSystem.java} (94%)
 delete mode 100644 log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/SpringEnvironmentHolder.java
 delete mode 100644 log4j-spring-boot/src/main/resources/META-INF/services/org.apache.logging.log4j.util.PropertySource
 rename log4j-spring-boot/src/test/java/org/apache/logging/log4j/spring/boot/{Log4j2CloudConfigLoggingSystemTest.java => Log4j2SpringBootLoggingSystemTest.java} (87%)


[logging-log4j2] 01/02: LOG4J2-3588 - Allow a PropertySource to be added

Posted by rg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rgoers pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 53b01c88809ced74fe6d0012b98510f4c42e6eb3
Author: Ralph Goers <rg...@apache.org>
AuthorDate: Mon Sep 5 12:40:54 2022 -0700

    LOG4J2-3588 - Allow a PropertySource to be added
---
 .../apache/logging/log4j/util/PropertiesUtil.java   | 21 ++++++++++++++++++++-
 ...emPropertiesPropertySourceSecurityManagerIT.java |  5 +++--
 ...stem.java => Log4j2SpringBootLoggingSystem.java} | 16 +++++++---------
 .../org.apache.logging.log4j.util.PropertySource    | 15 ---------------
 ....java => Log4j2SpringBootLoggingSystemTest.java} |  8 ++++----
 src/changes/changes.xml                             |  3 +++
 6 files changed, 37 insertions(+), 31 deletions(-)

diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java b/log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java
index d5decfe0e4..47fcb7151b 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/util/PropertiesUtil.java
@@ -34,6 +34,7 @@ import java.util.ServiceLoader;
 import java.util.Set;
 import java.util.TreeSet;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentSkipListSet;
 
 /**
  * <em>Consider this class private.</em>
@@ -121,6 +122,16 @@ public final class PropertiesUtil {
         return LOG4J_PROPERTIES;
     }
 
+    /**
+     * Allows a PropertySource to be added after PropertiesUtil has been created.
+     * @param propertySource the PropertySource to add.
+     */
+    public void addPropertySource(PropertySource propertySource) {
+        if (environment != null) {
+            environment.addPropertySource(propertySource);
+        }
+    }
+
     /**
      * Returns {@code true} if the specified property is defined, regardless of its value (it may not have a value).
      *
@@ -432,7 +443,7 @@ public final class PropertiesUtil {
      */
     private static class Environment {
 
-        private final Set<PropertySource> sources = new TreeSet<>(new PropertySource.Comparator());
+        private final Set<PropertySource> sources = new ConcurrentSkipListSet<>(new PropertySource.Comparator());
         /**
          * Maps a key to its value in the lowest priority source that contains it.
          */
@@ -463,6 +474,14 @@ public final class PropertiesUtil {
             reload();
         }
 
+        /**
+         * Allow a PropertySource to be added.
+         * @param propertySource The PropertySource to add.
+         */
+        public void addPropertySource(PropertySource propertySource) {
+            sources.add(propertySource);
+        }
+
         private synchronized void reload() {
             literal.clear();
             normalized.clear();
diff --git a/log4j-api/src/test/java/org/apache/logging/log4j/util/SystemPropertiesPropertySourceSecurityManagerIT.java b/log4j-api/src/test/java/org/apache/logging/log4j/util/SystemPropertiesPropertySourceSecurityManagerIT.java
index bd7932d30e..eabf5bde34 100644
--- a/log4j-api/src/test/java/org/apache/logging/log4j/util/SystemPropertiesPropertySourceSecurityManagerIT.java
+++ b/log4j-api/src/test/java/org/apache/logging/log4j/util/SystemPropertiesPropertySourceSecurityManagerIT.java
@@ -53,8 +53,9 @@ public class SystemPropertiesPropertySourceSecurityManagerIT {
 	private static class TestSecurityManager extends SecurityManager {
 		@Override
 		public void checkPermission(final Permission permission) {
-			if (permission instanceof PropertyPermission) {
-				throw new SecurityException();
+			if (permission instanceof PropertyPermission &&
+					!permission.getName().equals("java.util.secureRandomSeed")) {
+				throw new SecurityException("Unexpected permission: " + permission);
 			}
 		}
 	}
diff --git a/log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/Log4j2CloudConfigLoggingSystem.java b/log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/Log4j2SpringBootLoggingSystem.java
similarity index 94%
rename from log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/Log4j2CloudConfigLoggingSystem.java
rename to log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/Log4j2SpringBootLoggingSystem.java
index 5186579d70..809c38acb0 100644
--- a/log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/Log4j2CloudConfigLoggingSystem.java
+++ b/log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/Log4j2SpringBootLoggingSystem.java
@@ -30,7 +30,6 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.Properties;
-import javax.net.ssl.HttpsURLConnection;
 
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
@@ -45,19 +44,16 @@ import org.apache.logging.log4j.core.net.ssl.SslConfiguration;
 import org.apache.logging.log4j.core.net.ssl.SslConfigurationFactory;
 import org.apache.logging.log4j.core.util.AuthorizationProvider;
 import org.apache.logging.log4j.core.util.FileUtils;
-import org.apache.logging.log4j.internal.LogManagerStatus;
 import org.apache.logging.log4j.status.StatusLogger;
 import org.apache.logging.log4j.util.PropertiesUtil;
 import org.apache.logging.log4j.util.Strings;
-import org.springframework.boot.context.properties.bind.BindResult;
-import org.springframework.boot.context.properties.bind.Bindable;
-import org.springframework.boot.context.properties.bind.Binder;
 import org.springframework.boot.logging.LogFile;
 import org.springframework.boot.logging.LoggingInitializationContext;
 import org.springframework.boot.logging.LoggingSystem;
 import org.springframework.boot.logging.LoggingSystemFactory;
 import org.springframework.boot.logging.log4j2.Log4J2LoggingSystem;
 import org.springframework.core.annotation.Order;
+import org.springframework.core.env.Environment;
 import org.springframework.util.Assert;
 import org.springframework.util.ClassUtils;
 import org.springframework.util.ResourceUtils;
@@ -65,7 +61,7 @@ import org.springframework.util.ResourceUtils;
 /**
  * Override Spring's implementation of the Log4j 2 Logging System to properly support Spring Cloud Config.
  */
-public class Log4j2CloudConfigLoggingSystem extends Log4J2LoggingSystem {
+public class Log4j2SpringBootLoggingSystem extends Log4J2LoggingSystem {
 
     /**
      * Property that disables the usage of this {@link LoggingSystem}.
@@ -78,7 +74,7 @@ public class Log4j2CloudConfigLoggingSystem extends Log4J2LoggingSystem {
     private static Logger LOGGER = StatusLogger.getLogger();
     private static final int PRECEDENCE = 0;
 
-    public Log4j2CloudConfigLoggingSystem(ClassLoader loader) {
+    public Log4j2SpringBootLoggingSystem(ClassLoader loader) {
         super(loader);
     }
 
@@ -92,7 +88,9 @@ public class Log4j2CloudConfigLoggingSystem extends Log4J2LoggingSystem {
      */
     @Override
     public void initialize(LoggingInitializationContext initializationContext, String configLocation, LogFile logFile) {
-        getLoggerContext().putObjectIfAbsent(ENVIRONMENT_KEY, initializationContext.getEnvironment());
+        Environment environment = initializationContext.getEnvironment();
+        PropertiesUtil.getProperties().addPropertySource(new SpringPropertySource(environment));
+        getLoggerContext().putObjectIfAbsent(ENVIRONMENT_KEY, environment);
         super.initialize(initializationContext, configLocation, logFile);
     }
 
@@ -261,7 +259,7 @@ public class Log4j2CloudConfigLoggingSystem extends Log4J2LoggingSystem {
             if (PropertiesUtil.getProperties().getBooleanProperty(LOG4J2_DISABLE_CLOUD_CONFIG_LOGGING_SYSTEM)) {
                 return null;
             }
-            return new Log4j2CloudConfigLoggingSystem(classLoader);
+            return new Log4j2SpringBootLoggingSystem(classLoader);
         }
 
     }
diff --git a/log4j-spring-boot/src/main/resources/META-INF/services/org.apache.logging.log4j.util.PropertySource b/log4j-spring-boot/src/main/resources/META-INF/services/org.apache.logging.log4j.util.PropertySource
deleted file mode 100644
index 890387156f..0000000000
--- a/log4j-spring-boot/src/main/resources/META-INF/services/org.apache.logging.log4j.util.PropertySource
+++ /dev/null
@@ -1,15 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache license, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the license for the specific language governing permissions and
-# limitations under the license.
-org.apache.logging.log4j.spring.boot.SpringPropertySource
diff --git a/log4j-spring-boot/src/test/java/org/apache/logging/log4j/spring/boot/Log4j2CloudConfigLoggingSystemTest.java b/log4j-spring-boot/src/test/java/org/apache/logging/log4j/spring/boot/Log4j2SpringBootLoggingSystemTest.java
similarity index 87%
rename from log4j-spring-boot/src/test/java/org/apache/logging/log4j/spring/boot/Log4j2CloudConfigLoggingSystemTest.java
rename to log4j-spring-boot/src/test/java/org/apache/logging/log4j/spring/boot/Log4j2SpringBootLoggingSystemTest.java
index 3731f232c9..83ca4b329c 100644
--- a/log4j-spring-boot/src/test/java/org/apache/logging/log4j/spring/boot/Log4j2CloudConfigLoggingSystemTest.java
+++ b/log4j-spring-boot/src/test/java/org/apache/logging/log4j/spring/boot/Log4j2SpringBootLoggingSystemTest.java
@@ -29,7 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 import java.util.Arrays;
 import java.util.List;
 
-public class Log4j2CloudConfigLoggingSystemTest {
+public class Log4j2SpringBootLoggingSystemTest {
 
     @Test
     public void getStandardConfigLocations() {
@@ -37,7 +37,7 @@ public class Log4j2CloudConfigLoggingSystemTest {
         LoggerContext lc = LogManager.getContext(); // Initialize LogManager to here to prevent a failure trying to
                                                     // initialize it from StatusLogger.
         System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, customLog4j2Location);
-        Log4j2CloudConfigLoggingSystem cloudLoggingSystem = new Log4j2CloudConfigLoggingSystem(
+        Log4j2SpringBootLoggingSystem cloudLoggingSystem = new Log4j2SpringBootLoggingSystem(
                 this.getClass().getClassLoader());
         List<String> standardConfigLocations = Arrays.asList(cloudLoggingSystem.getStandardConfigLocations());
         assertTrue(standardConfigLocations.contains(customLog4j2Location));
@@ -45,7 +45,7 @@ public class Log4j2CloudConfigLoggingSystemTest {
     }
 
     @Test
-    @SetSystemProperty(key = Log4j2CloudConfigLoggingSystem.LOG4J2_DISABLE_CLOUD_CONFIG_LOGGING_SYSTEM, value = "true")
+    @SetSystemProperty(key = Log4j2SpringBootLoggingSystem.LOG4J2_DISABLE_CLOUD_CONFIG_LOGGING_SYSTEM, value = "true")
     public void testUseLog4j2LoggingSystem() {
         LoggingSystem loggingSystem = LoggingSystem.get(getClass().getClassLoader());
         assertTrue(loggingSystem.getClass().equals(Log4J2LoggingSystem.class));
@@ -54,6 +54,6 @@ public class Log4j2CloudConfigLoggingSystemTest {
     @Test
     public void testLoggingSystemEnabled() {
         LoggingSystem loggingSystem = LoggingSystem.get(getClass().getClassLoader());
-        assertTrue(loggingSystem.getClass().equals(Log4j2CloudConfigLoggingSystem.class));
+        assertTrue(loggingSystem.getClass().equals(Log4j2SpringBootLoggingSystem.class));
     }
 }
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 408b4d19f7..dc4c9fde56 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -30,6 +30,9 @@
          - "remove" - Removed
     -->
     <release version="2.19.0" date="2022-MM-DD" description="GA Release 2.19.0">
+      <action issue="LOG4J2-3588" dev="rgoers" type="update">
+        Allow PropertySources to be added.
+      </action>
       <action issue="LOG4J2-3578" dev="rgoers" type="fix">
         Generate new SSL certs for testing.
       </action>


[logging-log4j2] 02/02: LOG4J2-3589 - Allow Plugins to be injected with the LoggerContext reference

Posted by rg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rgoers pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 84a0f4e1379a7536a0496de8885b68109ae1cd8c
Author: Ralph Goers <rg...@apache.org>
AuthorDate: Tue Sep 6 11:45:30 2022 -0700

    LOG4J2-3589 - Allow Plugins to be injected with the LoggerContext reference
---
 .../log4j/core/config/AbstractConfiguration.java   |  7 ++-
 .../log4j/core/config/LoggerContextAware.java      | 35 +++++++++++++++
 .../core/config/plugins/PluginLoggerContext.java   | 37 ++++++++++++++++
 .../visitors/PluginLoggerContextVisitor.java       | 47 ++++++++++++++++++++
 .../lookup/AbstractLoggerContextAwareLookup.java   | 35 +++++++++++++++
 .../logging/log4j/core/lookup/Interpolator.java    | 17 +++++++-
 .../log4j/spring/boot/SpringEnvironmentHolder.java | 50 ----------------------
 .../logging/log4j/spring/boot/SpringLookup.java    | 43 +++++++++++--------
 .../log4j/spring/boot/SpringProfileArbiter.java    | 37 +++++++++++++---
 .../log4j/spring/boot/SpringPropertySource.java    | 10 +++--
 .../src/main/resources/META-INF/spring.factories   |  2 +-
 .../spring/boot/Log4j2SpringBootInitTest.java      |  2 +
 .../log4j/spring/boot/SpringLookupTest.java        | 10 +++--
 .../log4j/spring/boot/SpringProfileTest.java       |  2 +-
 src/changes/changes.xml                            |  3 ++
 15 files changed, 253 insertions(+), 84 deletions(-)

diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
index ab51e5d99d..2fa049b16c 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
@@ -132,7 +132,7 @@ public abstract class AbstractConfiguration extends AbstractFilterable implement
     private ConcurrentMap<String, LoggerConfig> loggerConfigs = new ConcurrentHashMap<>();
     private List<CustomLevelConfig> customLevels = Collections.emptyList();
     private final ConcurrentMap<String, String> propertyMap = new ConcurrentHashMap<>();
-    private final StrLookup tempLookup = new Interpolator(propertyMap);
+    private final Interpolator tempLookup = new Interpolator(propertyMap);
     private final StrSubstitutor runtimeStrSubstitutor = new RuntimeStrSubstitutor(tempLookup);
     private final StrSubstitutor configurationStrSubstitutor = new ConfigurationStrSubstitutor(runtimeStrSubstitutor);
     private LoggerConfig root = new LoggerConfig();
@@ -150,6 +150,7 @@ public abstract class AbstractConfiguration extends AbstractFilterable implement
      */
     protected AbstractConfiguration(final LoggerContext loggerContext, final ConfigurationSource configurationSource) {
         this.loggerContext = new WeakReference<>(loggerContext);
+        tempLookup.setLoggerContext(loggerContext);
         // The loggerContext is null for the NullConfiguration class.
         // this.loggerContext = new WeakReference(Objects.requireNonNull(loggerContext, "loggerContext is null"));
         this.configurationSource = Objects.requireNonNull(configurationSource, "configurationSource is null");
@@ -636,6 +637,9 @@ public abstract class AbstractConfiguration extends AbstractFilterable implement
             createConfiguration(first, null);
             if (first.getObject() != null) {
                 StrLookup lookup = (StrLookup) first.getObject();
+                if (lookup instanceof LoggerContextAware) {
+                    ((LoggerContextAware) lookup).setLoggerContext(loggerContext.get());
+                }
                 runtimeStrSubstitutor.setVariableResolver(lookup);
                 configurationStrSubstitutor.setVariableResolver(lookup);
             }
@@ -643,6 +647,7 @@ public abstract class AbstractConfiguration extends AbstractFilterable implement
             final Map<String, String> map = this.getComponent(CONTEXT_PROPERTIES);
             final StrLookup lookup = map == null ? null : new PropertiesLookup(map);
             Interpolator interpolator = new Interpolator(lookup, pluginPackages);
+            interpolator.setLoggerContext(loggerContext.get());
             runtimeStrSubstitutor.setVariableResolver(interpolator);
             configurationStrSubstitutor.setVariableResolver(interpolator);
         }
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LoggerContextAware.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LoggerContextAware.java
new file mode 100644
index 0000000000..e68af4c277
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LoggerContextAware.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.logging.log4j.core.config;
+
+import org.apache.logging.log4j.core.LoggerContext;
+
+/**
+ * Indicates that a class requests the current LoggerContext to be injected.
+ *
+ * @since 2.19.0
+ */
+public interface LoggerContextAware {
+
+    /**
+     * Injects the current LoggerContext into this object.
+     *
+     * @param loggerContext the current LoggerContext
+     */
+    void setLoggerContext(LoggerContext loggerContext);
+}
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginLoggerContext.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginLoggerContext.java
new file mode 100644
index 0000000000..9594ff4b1a
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/PluginLoggerContext.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.config.plugins;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.apache.logging.log4j.core.config.plugins.visitors.PluginLoggerContextVisitor;
+
+/**
+ * Identifies a parameter or field as a LoggerContext.
+ * @see org.apache.logging.log4j.core.LoggerContext
+ */
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.PARAMETER, ElementType.FIELD})
+@PluginVisitorStrategy(PluginLoggerContextVisitor.class)
+public @interface PluginLoggerContext {
+    // empty
+}
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginLoggerContextVisitor.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginLoggerContextVisitor.java
new file mode 100644
index 0000000000..6166831899
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/plugins/visitors/PluginLoggerContextVisitor.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.logging.log4j.core.config.plugins.visitors;
+
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.config.Node;
+import org.apache.logging.log4j.core.config.plugins.PluginConfiguration;
+
+/**
+ * PluginVisitor implementation for {@link PluginConfiguration}.
+ */
+public class PluginLoggerContextVisitor extends AbstractPluginVisitor<PluginConfiguration> {
+    public PluginLoggerContextVisitor() {
+        super(PluginConfiguration.class);
+    }
+
+    @Override
+    public Object visit(final Configuration configuration, final Node node, final LogEvent event,
+                        final StringBuilder log) {
+        if (this.conversionType.isAssignableFrom(LoggerContext.class)) {
+            if (configuration.getLoggerContext() != null) {
+                return configuration.getLoggerContext();
+            } else {
+                LOGGER.warn("Configuration {} is not assigned a LoggerContext", configuration.getName());
+            }
+        }
+        LOGGER.warn("Variable annotated with @PluginLoggerContext does not reference a LoggerContext");
+        return null;
+    }
+}
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/AbstractLoggerContextAwareLookup.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/AbstractLoggerContextAwareLookup.java
new file mode 100644
index 0000000000..bec6b4cc9f
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/AbstractLoggerContextAwareLookup.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.logging.log4j.core.lookup;
+
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.config.LoggerContextAware;
+
+/**
+ * StrLookup that is ConfigurationAware. Handles saving the Configuration.
+ *
+ * @since 2.6
+ */
+public abstract class AbstractLoggerContextAwareLookup extends AbstractLookup implements LoggerContextAware {
+    protected LoggerContext loggerContext;
+
+    @Override
+    public void setLoggerContext(final LoggerContext loggerContext) {
+        this.loggerContext = loggerContext;
+    }
+}
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java
index 44c72b7e4e..0660b61979 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java
@@ -24,7 +24,9 @@ import java.util.Map;
 
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.config.ConfigurationAware;
+import org.apache.logging.log4j.core.config.LoggerContextAware;
 import org.apache.logging.log4j.core.config.plugins.util.PluginManager;
 import org.apache.logging.log4j.core.config.plugins.util.PluginType;
 import org.apache.logging.log4j.core.net.JndiManager;
@@ -34,7 +36,7 @@ import org.apache.logging.log4j.status.StatusLogger;
 /**
  * Proxies all the other {@link StrLookup}s.
  */
-public class Interpolator extends AbstractConfigurationAwareLookup {
+public class Interpolator extends AbstractConfigurationAwareLookup implements LoggerContextAware {
 
     /** Constant for the prefix separator. */
     public static final char PREFIX_SEPARATOR = ':';
@@ -57,6 +59,8 @@ public class Interpolator extends AbstractConfigurationAwareLookup {
 
     private final StrLookup defaultLookup;
 
+    protected LoggerContext loggerContext;
+
     public Interpolator(final StrLookup defaultLookup) {
         this(defaultLookup, null);
     }
@@ -185,6 +189,9 @@ public class Interpolator extends AbstractConfigurationAwareLookup {
             if (lookup instanceof ConfigurationAware) {
                 ((ConfigurationAware) lookup).setConfiguration(configuration);
             }
+            if (lookup instanceof LoggerContextAware) {
+                ((LoggerContextAware) lookup).setLoggerContext(loggerContext);
+            }
             LookupResult value = null;
             if (lookup != null) {
                 value = event == null ? lookup.evaluate(name) : lookup.evaluate(event, name);
@@ -201,6 +208,14 @@ public class Interpolator extends AbstractConfigurationAwareLookup {
         return null;
     }
 
+    @Override
+    public void setLoggerContext(LoggerContext loggerContext) {
+        if (loggerContext == null) {
+            return;
+        }
+        this.loggerContext = loggerContext;
+    }
+
     @Override
     public String toString() {
         final StringBuilder sb = new StringBuilder();
diff --git a/log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/SpringEnvironmentHolder.java b/log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/SpringEnvironmentHolder.java
deleted file mode 100644
index 5c4403ddd5..0000000000
--- a/log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/SpringEnvironmentHolder.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.spring.boot;
-
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.internal.LogManagerStatus;
-import org.springframework.core.env.Environment;
-
-/**
- * Provides access to the Spring Environment.
- */
-public class SpringEnvironmentHolder {
-
-    private volatile Environment environment;
-    private Lock lock = new ReentrantLock();
-
-
-    protected Environment getEnvironment() {
-        if (environment == null && LogManagerStatus.isInitialized() && LogManager.getFactory() != null &&
-                LogManager.getFactory().hasContext(SpringEnvironmentHolder.class.getName(), null, false)) {
-            lock.lock();
-            try {
-                if (environment == null) {
-                    Object obj = LogManager.getContext(false).getObject(Log4j2CloudConfigLoggingSystem.ENVIRONMENT_KEY);
-                    environment = obj instanceof Environment ? (Environment) obj : null;
-                }
-            } finally {
-                lock.unlock();
-            }
-        }
-        return environment;
-    }
-}
diff --git a/log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/SpringLookup.java b/log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/SpringLookup.java
index 401cbdee19..7bbe26b892 100644
--- a/log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/SpringLookup.java
+++ b/log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/SpringLookup.java
@@ -21,7 +21,9 @@ import java.util.regex.Pattern;
 
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.lookup.AbstractLoggerContextAwareLookup;
 import org.apache.logging.log4j.core.lookup.StrLookup;
 import org.apache.logging.log4j.core.util.Integers;
 import org.apache.logging.log4j.status.StatusLogger;
@@ -31,7 +33,7 @@ import org.springframework.core.env.Environment;
  * Lookup for Spring properties.
  */
 @Plugin(name = "spring", category = StrLookup.CATEGORY)
-public class SpringLookup extends SpringEnvironmentHolder implements StrLookup {
+public class SpringLookup extends AbstractLoggerContextAwareLookup implements StrLookup {
 
     private static final Logger LOGGER = StatusLogger.getLogger();
     private static final String ACTIVE = "profiles.active";
@@ -40,30 +42,27 @@ public class SpringLookup extends SpringEnvironmentHolder implements StrLookup {
     private static final Pattern ACTIVE_PATTERN = Pattern.compile(ACTIVE + PATTERN);
     private static final Pattern DEFAULT_PATTERN = Pattern.compile(DEFAULT + PATTERN);
 
-    public SpringLookup() {
-        getEnvironment();
-    }
+    private volatile Environment environment;
 
     @Override
     public String lookup(String key) {
-        Environment env = getEnvironment();
-        if (env != null) {
+        if (environment != null) {
             String lowerKey = key.toLowerCase();
             if (lowerKey.startsWith(ACTIVE)) {
-                switch (env.getActiveProfiles().length) {
+                switch (environment.getActiveProfiles().length) {
                     case 0: {
                         return null;
                     }
                     case 1: {
-                        return env.getActiveProfiles()[0];
+                        return environment.getActiveProfiles()[0];
                     }
                     default: {
                         Matcher matcher = ACTIVE_PATTERN.matcher(key);
                         if (matcher.matches()) {
                             try {
                                 int index = Integers.parseInt(matcher.group(1));
-                                if (index < env.getActiveProfiles().length) {
-                                    return env.getActiveProfiles()[index];
+                                if (index < environment.getActiveProfiles().length) {
+                                    return environment.getActiveProfiles()[index];
                                 }
                                 LOGGER.warn("Index out of bounds for Spring active profiles: {}", index);
                                 return null;
@@ -73,24 +72,24 @@ public class SpringLookup extends SpringEnvironmentHolder implements StrLookup {
                             }
 
                         }
-                        return String.join(",", env.getActiveProfiles());
+                        return String.join(",", environment.getActiveProfiles());
                     }
                 }
             } else if (lowerKey.startsWith(DEFAULT)) {
-                switch (env.getDefaultProfiles().length) {
+                switch (environment.getDefaultProfiles().length) {
                     case 0: {
                         return null;
                     }
                     case 1: {
-                        return env.getDefaultProfiles()[0];
+                        return environment.getDefaultProfiles()[0];
                     }
                     default: {
                         Matcher matcher = DEFAULT_PATTERN.matcher(key);
                         if (matcher.matches()) {
                             try {
                                 int index = Integer.parseInt(matcher.group(1));
-                                if (index < env.getDefaultProfiles().length) {
-                                    return env.getDefaultProfiles()[index];
+                                if (index < environment.getDefaultProfiles().length) {
+                                    return environment.getDefaultProfiles()[index];
                                 }
                                 LOGGER.warn("Index out of bounds for Spring default profiles: {}", index);
                                 return null;
@@ -100,12 +99,12 @@ public class SpringLookup extends SpringEnvironmentHolder implements StrLookup {
                             }
 
                         }
-                        return String.join(",", env.getDefaultProfiles());
+                        return String.join(",", environment.getDefaultProfiles());
                     }
                 }
             }
 
-            return env.getProperty(key);
+            return environment.getProperty(key);
 
         }
         return null;
@@ -115,4 +114,14 @@ public class SpringLookup extends SpringEnvironmentHolder implements StrLookup {
     public String lookup(LogEvent event, String key) {
         return lookup((key));
     }
+
+    @Override
+    public void setLoggerContext(final LoggerContext loggerContext) {
+        if (loggerContext != null) {
+            super.setLoggerContext(loggerContext);
+            environment = (Environment) loggerContext.getObject(Log4j2SpringBootLoggingSystem.ENVIRONMENT_KEY);
+        } else {
+            LOGGER.warn("Attempt to set LoggerContext reference to null in SpringLookup");
+        }
+    }
 }
diff --git a/log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/SpringProfileArbiter.java b/log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/SpringProfileArbiter.java
index 6c6cdc62f3..29600bdc55 100644
--- a/log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/SpringProfileArbiter.java
+++ b/log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/SpringProfileArbiter.java
@@ -16,6 +16,8 @@
  */
 package org.apache.logging.log4j.spring.boot;
 
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.Node;
 import org.apache.logging.log4j.core.config.arbiters.Arbiter;
@@ -23,6 +25,8 @@ import org.apache.logging.log4j.core.config.plugins.Plugin;
 import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute;
 import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
 import org.apache.logging.log4j.core.config.plugins.PluginConfiguration;
+import org.apache.logging.log4j.core.config.plugins.PluginLoggerContext;
+import org.apache.logging.log4j.status.StatusLogger;
 import org.springframework.core.env.Environment;
 import org.springframework.core.env.Profiles;
 import org.springframework.util.StringUtils;
@@ -32,18 +36,18 @@ import org.springframework.util.StringUtils;
  */
 @Plugin(name = "SpringProfile", category = Node.CATEGORY, elementType = Arbiter.ELEMENT_TYPE,
         deferChildren = true, printObject = true)
-public class SpringProfileArbiter extends SpringEnvironmentHolder implements Arbiter {
+public class SpringProfileArbiter implements Arbiter {
 
     private final String[] profileNames;
+    private final Environment environment;
 
-    private SpringProfileArbiter(final String[] profiles) {
+    private SpringProfileArbiter(final String[] profiles, Environment environment) {
         this.profileNames = profiles;
-
+        this.environment = environment;
     }
 
     @Override
     public boolean isCondition() {
-        Environment environment = getEnvironment();
         if (environment == null) {
             return false;
         }
@@ -61,13 +65,17 @@ public class SpringProfileArbiter extends SpringEnvironmentHolder implements Arb
 
     public static class Builder implements org.apache.logging.log4j.core.util.Builder<SpringProfileArbiter> {
 
+        private final Logger LOGGER = StatusLogger.getLogger();
         public static final String ATTR_NAME = "name";
 
         @PluginBuilderAttribute(ATTR_NAME)
         private String name;
 
         @PluginConfiguration
-        private Configuration configuration;;
+        private Configuration configuration;
+
+        @PluginLoggerContext
+        private LoggerContext loggerContext;
 
         /**
          * Sets the Profile Name or Names.
@@ -84,6 +92,11 @@ public class SpringProfileArbiter extends SpringEnvironmentHolder implements Arb
             return asBuilder();
         }
 
+        public Builder setLoggerContext(final LoggerContext loggerContext) {
+            this.loggerContext = loggerContext;
+            return asBuilder();
+        }
+
         private SpringProfileArbiter.Builder asBuilder() {
             return this;
         }
@@ -91,7 +104,19 @@ public class SpringProfileArbiter extends SpringEnvironmentHolder implements Arb
         public SpringProfileArbiter build() {
             String[] profileNames = StringUtils.trimArrayElements(
                     StringUtils.commaDelimitedListToStringArray(configuration.getStrSubstitutor().replace(name)));
-            return new SpringProfileArbiter(profileNames);
+            Environment environment = null;
+            if (loggerContext != null) {
+                environment = (Environment) loggerContext.getObject(Log4j2SpringBootLoggingSystem.ENVIRONMENT_KEY);
+                if (environment == null) {
+                    LOGGER.warn("Cannot create Arbiter, no Spring Environment provided");
+                    return null;
+                }
+
+                return new SpringProfileArbiter(profileNames, environment);
+            } else {
+                LOGGER.warn("Cannot create Arbiter, LoggerContext is not available");
+            }
+            return null;
         }
     }
 }
diff --git a/log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/SpringPropertySource.java b/log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/SpringPropertySource.java
index 5749bb7ab5..a10b397a10 100644
--- a/log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/SpringPropertySource.java
+++ b/log4j-spring-boot/src/main/java/org/apache/logging/log4j/spring/boot/SpringPropertySource.java
@@ -22,10 +22,16 @@ import org.springframework.core.env.Environment;
 /**
  * Returns properties from Spring.
  */
-public class SpringPropertySource extends SpringEnvironmentHolder implements PropertySource {
+public class SpringPropertySource implements PropertySource {
 
     private static final int DEFAULT_PRIORITY = -100;
 
+    private final Environment environment;
+
+    public SpringPropertySource(Environment environment) {
+        this.environment = environment;
+    }
+
     /**
      * System properties take precendence followed by properties in Log4j properties files. Spring properties
      * follow.
@@ -38,7 +44,6 @@ public class SpringPropertySource extends SpringEnvironmentHolder implements Pro
 
     @Override
     public String getProperty(String key) {
-        Environment environment = getEnvironment();
         if (environment != null) {
             return environment.getProperty(key);
         }
@@ -47,7 +52,6 @@ public class SpringPropertySource extends SpringEnvironmentHolder implements Pro
 
     @Override
     public boolean containsProperty(String key) {
-        Environment environment = getEnvironment();
         if (environment != null) {
             return environment.containsProperty(key);
         }
diff --git a/log4j-spring-boot/src/main/resources/META-INF/spring.factories b/log4j-spring-boot/src/main/resources/META-INF/spring.factories
index 4ee1569639..c9f555714e 100644
--- a/log4j-spring-boot/src/main/resources/META-INF/spring.factories
+++ b/log4j-spring-boot/src/main/resources/META-INF/spring.factories
@@ -14,4 +14,4 @@
 # See the license for the specific language governing permissions and
 # limitations under the license.
 #
-org.springframework.boot.logging.LoggingSystemFactory=org.apache.logging.log4j.spring.boot.Log4j2CloudConfigLoggingSystem.Factory
\ No newline at end of file
+org.springframework.boot.logging.LoggingSystemFactory=org.apache.logging.log4j.spring.boot.Log4j2SpringBootLoggingSystem.Factory
\ No newline at end of file
diff --git a/log4j-spring-boot/src/test/java/org/apache/logging/log4j/spring/boot/Log4j2SpringBootInitTest.java b/log4j-spring-boot/src/test/java/org/apache/logging/log4j/spring/boot/Log4j2SpringBootInitTest.java
index fd36fc26a8..a6afb2fe32 100644
--- a/log4j-spring-boot/src/test/java/org/apache/logging/log4j/spring/boot/Log4j2SpringBootInitTest.java
+++ b/log4j-spring-boot/src/test/java/org/apache/logging/log4j/spring/boot/Log4j2SpringBootInitTest.java
@@ -54,7 +54,9 @@ public class Log4j2SpringBootInitTest {
 
         @Override
         public void run(ApplicationArguments args) throws Exception {
+            LoggerContext context = (LoggerContext) LogManager.getContext(false);
             SpringLookup lookup = new SpringLookup();
+            lookup.setLoggerContext(context);
             LOGGER.info("Started: {}", lookup.lookup("spring.application.name"));
         }
     }
diff --git a/log4j-spring-boot/src/test/java/org/apache/logging/log4j/spring/boot/SpringLookupTest.java b/log4j-spring-boot/src/test/java/org/apache/logging/log4j/spring/boot/SpringLookupTest.java
index eb264f8e99..b0abe5cd7b 100644
--- a/log4j-spring-boot/src/test/java/org/apache/logging/log4j/spring/boot/SpringLookupTest.java
+++ b/log4j-spring-boot/src/test/java/org/apache/logging/log4j/spring/boot/SpringLookupTest.java
@@ -39,8 +39,9 @@ public class SpringLookupTest {
         env.setDefaultProfiles("one", "two");
         env.setProperty("app.property", "test");
         LoggerContext context = (LoggerContext) LogManager.getContext(false);
-        context.putObject(Log4j2CloudConfigLoggingSystem.ENVIRONMENT_KEY, env);
+        context.putObject(Log4j2SpringBootLoggingSystem.ENVIRONMENT_KEY, env);
         SpringLookup lookup = new SpringLookup();
+        lookup.setLoggerContext(context);
         String result = lookup.lookup("profiles.active");
         assertNotNull("No active profiles", result);
         assertEquals("Incorrect active profile", "test", result);
@@ -66,9 +67,10 @@ public class SpringLookupTest {
         env.setActiveProfiles("test");
         env.setProperty("app.property", "test");
         LoggerContext context = (LoggerContext) LogManager.getContext(false);
-        context.putObject(Log4j2CloudConfigLoggingSystem.ENVIRONMENT_KEY, env);
-
-        StrLookup lookup = new Interpolator();
+        context.putObject(Log4j2SpringBootLoggingSystem.ENVIRONMENT_KEY, env);
+        Interpolator lookup = new Interpolator();
+        lookup.setConfiguration(context.getConfiguration());
+        lookup.setLoggerContext(context);
         String result = lookup.lookup("spring:profiles.active");
         assertNotNull("No active profiles", result);
         assertEquals("Incorrect active profile", "test", result);
diff --git a/log4j-spring-boot/src/test/java/org/apache/logging/log4j/spring/boot/SpringProfileTest.java b/log4j-spring-boot/src/test/java/org/apache/logging/log4j/spring/boot/SpringProfileTest.java
index 3182ae3799..c35b08b7e9 100644
--- a/log4j-spring-boot/src/test/java/org/apache/logging/log4j/spring/boot/SpringProfileTest.java
+++ b/log4j-spring-boot/src/test/java/org/apache/logging/log4j/spring/boot/SpringProfileTest.java
@@ -43,7 +43,7 @@ public class SpringProfileTest {
     public static void before() {
         loggerContext = (LoggerContext) LogManager.getContext(false);
         env = new MockEnvironment();
-        loggerContext.putObject(Log4j2CloudConfigLoggingSystem.ENVIRONMENT_KEY, env);
+        loggerContext.putObject(Log4j2SpringBootLoggingSystem.ENVIRONMENT_KEY, env);
     }
 
 
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index dc4c9fde56..b3a531558f 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -30,6 +30,9 @@
          - "remove" - Removed
     -->
     <release version="2.19.0" date="2022-MM-DD" description="GA Release 2.19.0">
+      <action issue="LOG4J2-3589" dev="rgoers" type="update">
+        Allow Plugins to be injected with the LoggerContext reference.
+      </action>
       <action issue="LOG4J2-3588" dev="rgoers" type="update">
         Allow PropertySources to be added.
       </action>