title: Getting properties programmatically from Log4j2 XML config
body: <p>In my Log4j2 config file, I have this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Configuration status="WARN" strict="true" name="XMLConfig" packages="org.apache.logging.log4j.test"&gt;
      &lt;Properties&gt;
          &lt;Property name="baseDir"&gt;log-dir/&lt;/Property&gt;
          &lt;Property name="defaultLogfileName"&gt;default-log-file&lt;/Property&gt;
      &lt;/Properties&gt;
  </code></pre>
  
  <p>Now, in some of my code, I create custom loggers. I need to access the value of "baseDir" and change it. I've tried using <code>getProperties</code> from the context like this:</p>
  
  <pre><code>LoggerContext context = (LoggerContext) LogManager.getContext(false);
  Configuration configuration = context.getConfiguration();
  configuration.getProperties();
  </code></pre>
  
  <p>But the map that comes back has the keys "hostname" and "contextName". Not the properties map that I was looking for.</p>
  
  <p>I thought that I might be able to get it from the rootLogger:</p>
  
  <pre><code>LoggerContext context = (LoggerContext) LogManager.getContext(false);
  Configuration configuration = context.getConfiguration()
  for (Property p : configuration.getRootLogger().getPropertyList())
  {
      ...
  }
  </code></pre>
  
  <p>But this yields a NullPointerException because getPropertyList returns null.</p>
  
  <p>So, how can I access the property with the name "baseDir" so that I can programmatically create a new logger, but with a different base directory?</p>