logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rpo...@apache.org
Subject svn commit: r1616231 - in /logging/log4j/log4j2/trunk: log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java src/changes/changes.xml
Date Wed, 06 Aug 2014 13:30:43 GMT
Author: rpopma
Date: Wed Aug  6 13:30:43 2014
New Revision: 1616231

URL: http://svn.apache.org/r1616231
Log:
LOG4J2-730 Allow Log4jContextFactory subclasses to specify a custom ContextSelector

Modified:
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java
    logging/log4j/log4j2/trunk/src/changes/changes.xml

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java?rev=1616231&r1=1616230&r2=1616231&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java
Wed Aug  6 13:30:43 2014
@@ -41,20 +41,30 @@ public class Log4jContextFactory impleme
     private ContextSelector selector;
 
     /**
-     * Initializes the ContextSelector.
+     * Initializes the ContextSelector from system property {@link Constants#LOG4J_CONTEXT_SELECTOR}.
      */
     public Log4jContextFactory() {
+        this(createContextSelector());
+    }
+
+    /**
+     * Initializes this factory's ContextSelector with the specified selector.
+     * @param selector the selector to use
+     */
+    public Log4jContextFactory(final ContextSelector selector) {
+        this.selector = selector;
+    }
+
+    private static ContextSelector createContextSelector() {
         final String sel = PropertiesUtil.getProperties().getStringProperty(Constants.LOG4J_CONTEXT_SELECTOR);
         if (sel != null) {
             try {
-                selector = Loader.newCheckedInstanceOf(sel, ContextSelector.class);
+                return Loader.newCheckedInstanceOf(sel, ContextSelector.class);
             } catch (final Exception ex) {
                 LOGGER.error("Unable to create context {}", sel, ex);
             }
         }
-        if (selector == null) {
-            selector = new ClassLoaderContextSelector();
-        }
+        return new ClassLoaderContextSelector();
     }
 
     /**

Modified: logging/log4j/log4j2/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/changes/changes.xml?rev=1616231&r1=1616230&r2=1616231&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/changes/changes.xml (original)
+++ logging/log4j/log4j2/trunk/src/changes/changes.xml Wed Aug  6 13:30:43 2014
@@ -21,7 +21,10 @@
     <title>Changes</title>
   </properties>
   <body>
-    <release version="2.1" date="2014-0?-??" description="Bug fixes and enhancements">
+    <release version="2.0.2" date="2014-0?-??" description="Bug fixes and enhancements">
+      <action issue="LOG4J2-730" dev="rpopma" type="update">
+        Allow Log4jContextFactory subclasses to specify a custom ContextSelector.
+      </action>      
       <action issue="LOG4J2-759" dev="rpopma" type="fix">
         Fixed various minor site/documentation issues, mostly versioning related.
       </action>      



Mime
View raw message