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

mattsicker pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit e55649e72df545a1b79258b97baf285cd01a9c7a
Author: Matt Sicker <[email protected]>
AuthorDate: Sun Oct 15 19:09:22 2023 -0500

    Add Configuration::getContextProperties
    
    Signed-off-by: Matt Sicker <[email protected]>
---
 .../log4j/core/config/AbstractConfiguration.java       |  7 ++++++-
 .../logging/log4j/core/config/Configuration.java       | 18 +++++++++++++++++-
 2 files changed, 23 insertions(+), 2 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 ebf083b0da..5282161dd2 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
@@ -159,7 +159,7 @@ public abstract class AbstractConfiguration extends 
AbstractFilterable implement
     private AsyncLoggerConfigDisruptor asyncLoggerConfigDisruptor;
     private AsyncWaitStrategyFactory asyncWaitStrategyFactory;
     private final WeakReference<LoggerContext> loggerContext;
-    private PropertyEnvironment contextProperties;
+    private final PropertyEnvironment contextProperties;
     private final Lock configLock = new ReentrantLock();
 
     /**
@@ -203,6 +203,11 @@ public abstract class AbstractConfiguration extends 
AbstractFilterable implement
         return properties;
     }
 
+    @Override
+    public PropertyEnvironment getContextProperties() {
+        return contextProperties;
+    }
+
     @Override
     public ScriptManager getScriptManager() {
         return scriptManager;
diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configuration.java
 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configuration.java
index 76e28f9084..4e940bd396 100644
--- 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configuration.java
+++ 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configuration.java
@@ -34,9 +34,11 @@ import org.apache.logging.log4j.core.lookup.StrSubstitutor;
 import org.apache.logging.log4j.core.net.Advertiser;
 import org.apache.logging.log4j.core.script.ScriptManager;
 import org.apache.logging.log4j.core.time.NanoClock;
+import org.apache.logging.log4j.core.util.NetUtils;
 import org.apache.logging.log4j.core.util.WatchManager;
 import org.apache.logging.log4j.plugins.Node;
 import org.apache.logging.log4j.plugins.di.Key;
+import org.apache.logging.log4j.util.PropertyEnvironment;
 
 /**
  * Interface that must be implemented to create a configuration.
@@ -100,8 +102,22 @@ public interface Configuration extends Filterable {
 
     void removeLogger(final String name);
 
+    /**
+     * Returns the configuration properties. These will initially include 
entries for {@code contextName}
+     * with the {@linkplain 
org.apache.logging.log4j.spi.LoggerContext#getName() context name} and
+     * {@code hostName} with the {@linkplain NetUtils#getLocalHostname() local 
host name}. Additional
+     * properties may be defined by plugins.
+     */
     Map<String, String> getProperties();
 
+    /**
+     * Returns the {@linkplain 
org.apache.logging.log4j.spi.LoggerContext#getProperties() context properties}
+     * associated with the logger context for this configuration.
+     *
+     * @return the context properties
+     */
+    PropertyEnvironment getContextProperties();
+
     /**
      * Returns the root Logger.
      *
@@ -225,7 +241,7 @@ public interface Configuration extends Filterable {
     void setNanoClock(NanoClock nanoClock);
 
     /**
-     * Gets the logger context.
+     * Gets the logger context. This may be {@code null} if the context has 
already been stopped and garbage collected.
      *
      * @return the logger context.
      */

Reply via email to