title: How to edit and save existing log4j2 configuration
body: <p>I would like to load an existing log4j2 configuration (xml file), modify the configuration and then save it again (preferably without the configuration becoming active, I just want to edit it).</p>
  <p>I can load the file e.g. like this:</p>
  <pre><code>ConfigurationSource configurationSource = new ConfigurationSource(new FileInputStream(&quot;myConfigFile.xml&quot;));
  XmlConfiguration xmlConfig = new XmlConfiguration(loggerContext, configurationSource);
  </code></pre>
  <p>I can use ConfigurationBuilder to create a new configuration programmatically:</p>
  <pre><code>ConfigurationBuilder&lt;BuiltConfiguration&gt; builder = ConfigurationBuilderFactory.newConfigurationBuilder();
  
  // add appenders etc ...
  AppenderComponentBuilder console = builder.newAppender(&quot;stdout&quot;, &quot;Console&quot;); 
  builder.add(console);
  </code></pre>
  <p>and can then save it as XML:</p>
  <pre><code>FileOutputStream fos = new FileOutputStream(configFile);
  builder.writeXmlConfiguration(fos);
  </code></pre>
  <p>But how do I get these two actions to work together?<br />
  Can I load an existing configuration into ConfigurationBuilder, edit it there and then save it again with <code>writeXmlConfiguration</code>?<br />
  Or is there a way to save the XmlConfiguration?</p>