title: Why does Log4J2 look for config files with class loader strings in the filename?
body: <p>I'm trying to set up Log4J2 and got its <code>StatusLogger</code> printing to the console so I could understand why it wasn't seeing my config file (for the curious, I think the problem was the JSON library Log4J2 uses wasn't in my classpath so it silently failed, but unfortunately I'm not certain).</p>
  
  <p>However once I set the <code>StatusLogger</code> to print <code>TRACE</code> statements, I noticed something odd - it seems to be looking for resources with <code>sun.misc.Launcher$AppClassLoader.toString()</code> calls in the filename, e.g. (newlines added for readability):</p>
  
  <pre><code>2013-12-09 01:07:23,938 TRACE Trying to find 
      [log4j2sun.misc.Launcher$AppClassLoader@765291.json] 
      using context classloader sun.misc.Launcher$AppClassLoader@765291.
  </code></pre>
  
  <p>The file it's looking for is essentially <code>"log4j2"+classLoader+".json"</code> which struck me as odd.  But debugging through the config loading behavior, we see this stems from <code>ClassLoaderContextSelector.locateContext()</code> which does the following:</p>
  
  <pre><code>private LoggerContext locateContext(final ClassLoader loader, 
      final URI configLocation {
    final String name = loader.toString();
    ...
    LoggerContext ctx = new LoggerContext(name, null, configLocation);
    ...
  }
  </code></pre>
  
  <p>Which eventually leads to <code>ctx.start()</code> being called, which ultimately calls <code>Loader.getResource()</code> passing in the value of <code>loader.toString()</code> as part of the <code>resource</code> string.  Looking at it, the behavior seems fairly intention, but I cannot imagine why it would be beneficial to be looking for such a resource name.  What does this get us?  Is this a bug?</p>
  
  <hr>
  
  <p>SSCCE:</p>
  
  <pre><code>import org.apache.logging.log4j.Level;
  import org.apache.logging.log4j.LogManager;
  import org.apache.logging.log4j.status.StatusConsoleListener;
  import org.apache.logging.log4j.status.StatusLogger;
  
  public class L4JTrace {    
    public static void main(String[] args) {
      StatusConsoleListener listener = new StatusConsoleListener(Level.ALL);
      StatusLogger.getLogger().registerListener(listener);
      LogManager.getLogger(MyApp.class.getName());
    }
  }
  </code></pre>
  
  <p>This should output something like:</p>
  
  <pre><code>2013-12-09 01:22:27,132 WARN Multiple logging implementations found: 
  Factory: org.apache.logging.log4j.core.impl.Log4jContextFactory, Weighting: 10
  Using factory: org.apache.logging.log4j.core.impl.Log4jContextFactory
  2013-12-09 01:22:27,148 DEBUG ServletContext not present - WebLookup not added
  2013-12-09 01:22:27,160 DEBUG Found Plugin Map at jar:file:LOCALPATH
  2013-12-09 01:22:27,162 DEBUG ServletContext not present - WebLookup not added
  2013-12-09 01:22:27,202 WARN JmDNS or serviceInfo class not found java.lang.ClassNotFoundException: javax.jmdns.JmDNS # Exception truncated
  2013-12-09 01:22:27,221 DEBUG Generated plugins in 0.062408180 seconds
  2013-12-09 01:22:27,240 DEBUG Jansi is not installed, cannot find org.fusesource.jansi.WindowsAnsiOutputStream
  2013-12-09 01:22:27,241 DEBUG Starting OutputStreamManager SYSTEM_OUT
  2013-12-09 01:22:27,242 DEBUG Reconfiguration started for context sun.misc.Launcher$AppClassLoader@765291
  2013-12-09 01:22:27,242 DEBUG Generated plugins in 0.000013583 seconds
  2013-12-09 01:22:27,245 DEBUG ServletContext not present - WebLookup not added
  2013-12-09 01:22:27,245 DEBUG Missing dependencies for Json support
  2013-12-09 01:22:27,245 DEBUG ServletContext not present - WebLookup not added
  2013-12-09 01:22:27,245 TRACE Trying to find [log4j2-testsun.misc.Launcher$AppClassLoader@765291.json] using context classloader sun.misc.Launcher$AppClassLoader@765291.
  2013-12-09 01:22:27,246 TRACE Trying to find [log4j2-testsun.misc.Launcher$AppClassLoader@765291.json] using sun.misc.Launcher$AppClassLoader@765291 class loader.
  2013-12-09 01:22:27,246 TRACE Trying to find [log4j2-testsun.misc.Launcher$AppClassLoader@765291.json] using sun.misc.Launcher$AppClassLoader@765291 class loader.
  2013-12-09 01:22:27,246 TRACE Trying to find [log4j2-testsun.misc.Launcher$AppClassLoader@765291.json] using ClassLoader.getSystemResource().
  2013-12-09 01:22:27,246 TRACE Trying to find [log4j2-testsun.misc.Launcher$AppClassLoader@765291.jsn] using context classloader sun.misc.Launcher$AppClassLoader@765291.
  2013-12-09 01:22:27,246 TRACE Trying to find [log4j2-testsun.misc.Launcher$AppClassLoader@765291.jsn] using sun.misc.Launcher$AppClassLoader@765291 class loader.
  2013-12-09 01:22:27,247 TRACE Trying to find [log4j2-testsun.misc.Launcher$AppClassLoader@765291.jsn] using sun.misc.Launcher$AppClassLoader@765291 class loader.
  2013-12-09 01:22:27,247 TRACE Trying to find [log4j2-testsun.misc.Launcher$AppClassLoader@765291.jsn] using ClassLoader.getSystemResource().
  2013-12-09 01:22:27,247 TRACE Trying to find [log4j2-testsun.misc.Launcher$AppClassLoader@765291.xml] using context classloader sun.misc.Launcher$AppClassLoader@765291.
  2013-12-09 01:22:27,247 TRACE Trying to find [log4j2-testsun.misc.Launcher$AppClassLoader@765291.xml] using sun.misc.Launcher$AppClassLoader@765291 class loader.
  2013-12-09 01:22:27,247 TRACE Trying to find [log4j2-testsun.misc.Launcher$AppClassLoader@765291.xml] using sun.misc.Launcher$AppClassLoader@765291 class loader.
  2013-12-09 01:22:27,247 TRACE Trying to find [log4j2-testsun.misc.Launcher$AppClassLoader@765291.xml] using ClassLoader.getSystemResource().
  2013-12-09 01:22:27,248 TRACE Trying to find [log4j2-test.json] using context classloader sun.misc.Launcher$AppClassLoader@765291.
  2013-12-09 01:22:27,248 TRACE Trying to find [log4j2-test.json] using sun.misc.Launcher$AppClassLoader@765291 class loader.
  2013-12-09 01:22:27,248 TRACE Trying to find [log4j2-test.json] using sun.misc.Launcher$AppClassLoader@765291 class loader.
  2013-12-09 01:22:27,248 TRACE Trying to find [log4j2-test.json] using ClassLoader.getSystemResource().
  2013-12-09 01:22:27,248 TRACE Trying to find [log4j2-test.jsn] using context classloader sun.misc.Launcher$AppClassLoader@765291.
  2013-12-09 01:22:27,248 TRACE Trying to find [log4j2-test.jsn] using sun.misc.Launcher$AppClassLoader@765291 class loader.
  2013-12-09 01:22:27,248 TRACE Trying to find [log4j2-test.jsn] using sun.misc.Launcher$AppClassLoader@765291 class loader.
  2013-12-09 01:22:27,249 TRACE Trying to find [log4j2-test.jsn] using ClassLoader.getSystemResource().
  2013-12-09 01:22:27,249 TRACE Trying to find [log4j2-test.xml] using context classloader sun.misc.Launcher$AppClassLoader@765291.
  2013-12-09 01:22:27,249 TRACE Trying to find [log4j2-test.xml] using sun.misc.Launcher$AppClassLoader@765291 class loader.
  2013-12-09 01:22:27,249 TRACE Trying to find [log4j2-test.xml] using sun.misc.Launcher$AppClassLoader@765291 class loader.
  2013-12-09 01:22:27,249 TRACE Trying to find [log4j2-test.xml] using ClassLoader.getSystemResource().
  2013-12-09 01:22:27,250 TRACE Trying to find [log4j2sun.misc.Launcher$AppClassLoader@765291.json] using context classloader sun.misc.Launcher$AppClassLoader@765291.
  2013-12-09 01:22:27,250 TRACE Trying to find [log4j2sun.misc.Launcher$AppClassLoader@765291.json] using sun.misc.Launcher$AppClassLoader@765291 class loader.
  2013-12-09 01:22:27,250 TRACE Trying to find [log4j2sun.misc.Launcher$AppClassLoader@765291.json] using sun.misc.Launcher$AppClassLoader@765291 class loader.
  2013-12-09 01:22:27,250 TRACE Trying to find [log4j2sun.misc.Launcher$AppClassLoader@765291.json] using ClassLoader.getSystemResource().
  2013-12-09 01:22:27,250 TRACE Trying to find [log4j2sun.misc.Launcher$AppClassLoader@765291.jsn] using context classloader sun.misc.Launcher$AppClassLoader@765291.
  2013-12-09 01:22:27,251 TRACE Trying to find [log4j2sun.misc.Launcher$AppClassLoader@765291.jsn] using sun.misc.Launcher$AppClassLoader@765291 class loader.
  2013-12-09 01:22:27,251 TRACE Trying to find [log4j2sun.misc.Launcher$AppClassLoader@765291.jsn] using sun.misc.Launcher$AppClassLoader@765291 class loader.
  2013-12-09 01:22:27,251 TRACE Trying to find [log4j2sun.misc.Launcher$AppClassLoader@765291.jsn] using ClassLoader.getSystemResource().
  2013-12-09 01:22:27,251 TRACE Trying to find [log4j2sun.misc.Launcher$AppClassLoader@765291.xml] using context classloader sun.misc.Launcher$AppClassLoader@765291.
  2013-12-09 01:22:27,251 TRACE Trying to find [log4j2sun.misc.Launcher$AppClassLoader@765291.xml] using sun.misc.Launcher$AppClassLoader@765291 class loader.
  2013-12-09 01:22:27,251 TRACE Trying to find [log4j2sun.misc.Launcher$AppClassLoader@765291.xml] using sun.misc.Launcher$AppClassLoader@765291 class loader.
  2013-12-09 01:22:27,252 TRACE Trying to find [log4j2sun.misc.Launcher$AppClassLoader@765291.xml] using ClassLoader.getSystemResource().
  2013-12-09 01:22:27,252 TRACE Trying to find [log4j2.json] using context classloader sun.misc.Launcher$AppClassLoader@765291.
  2013-12-09 01:22:27,252 TRACE Trying to find [log4j2.json] using sun.misc.Launcher$AppClassLoader@765291 class loader.
  2013-12-09 01:22:27,252 TRACE Trying to find [log4j2.json] using sun.misc.Launcher$AppClassLoader@765291 class loader.
  2013-12-09 01:22:27,252 TRACE Trying to find [log4j2.json] using ClassLoader.getSystemResource().
  2013-12-09 01:22:27,252 TRACE Trying to find [log4j2.jsn] using context classloader sun.misc.Launcher$AppClassLoader@765291.
  2013-12-09 01:22:27,252 TRACE Trying to find [log4j2.jsn] using sun.misc.Launcher$AppClassLoader@765291 class loader.
  2013-12-09 01:22:27,253 TRACE Trying to find [log4j2.jsn] using sun.misc.Launcher$AppClassLoader@765291 class loader.
  2013-12-09 01:22:27,253 TRACE Trying to find [log4j2.jsn] using ClassLoader.getSystemResource().
  2013-12-09 01:22:27,253 TRACE Trying to find [log4j2.xml] using context classloader sun.misc.Launcher$AppClassLoader@765291.
  2013-12-09 01:22:27,253 TRACE Trying to find [log4j2.xml] using sun.misc.Launcher$AppClassLoader@765291 class loader.
  2013-12-09 01:22:27,253 TRACE Trying to find [log4j2.xml] using sun.misc.Launcher$AppClassLoader@765291 class loader.
  2013-12-09 01:22:27,253 TRACE Trying to find [log4j2.xml] using ClassLoader.getSystemResource().
  2013-12-09 01:22:27,254 DEBUG ServletContext not present - WebLookup not added
  2013-12-09 01:22:27,254 DEBUG Generated plugins in 0.000012075 seconds
  2013-12-09 01:22:27,254 DEBUG Jansi is not installed, cannot find org.fusesource.jansi.WindowsAnsiOutputStream
  2013-12-09 01:22:27,261 DEBUG Generated plugins in 0.000015998 seconds
  2013-12-09 01:22:27,261 DEBUG Reconfiguration completed
  2013-12-09 01:22:27,263 DEBUG ServletContext not present - WebLookup not added
  2013-12-09 01:22:27,264 DEBUG Shutting down OutputStreamManager SYSTEM_OUT
  </code></pre>