title: Create a separate log4j2 log for each forked java process
body: <p>I would like to have a separate log file created for each process forked by a main process.  </p>
  
  <p>In log4j2.xml, a log file name is declared as:</p>
  
  <pre><code>fileName="${sys:loggingFileName}.log"
  </code></pre>
  
  <p>In an initial class, say class A, a log is created:</p>
  
  <pre><code>public class A {
      System.setProperty ("loggingFileName", "MyLogA");
      log = LogManager.getLogger (A.class);
      ...
      log.info (...);
      ProcessBuilder pb = new ProcessBuilder ();
      Map&lt;String, String&gt; environment;
      environment = pb.environment ();
      environment.put ("CLASSPATH", System.getProperty ("java.class.path"));
      pb.command (Arrays.asList ("/usr/bin/java", "class B"));
      final Process process = pb.start ();
  }
  </code></pre>
  
  <p>Class B could look exactly as above (with the appropriate substitution of B for A, and C for the creation of the new class).</p>
  
  <p>When started separately (not through ProcessBuilder), Class A and class B each create a separate log as expected.</p>
  
  <p>However, when class B is forked from class A using ProcessBuilder, a MyLogA.log file is created containing the specified log entry, but no MyLogB.log.</p>
  
  <p>I don't understand why.  Any guidance is appreciated.</p>
  
  <p>Additionally: I have tried placing :</p>
  
  <pre><code>pb.redirectOutput (Redirect.INHERIT);
  pb.redirectError (Redirect.INHERIT);
  </code></pre>
  
  <p>or</p>
  
  <pre><code>pb.redirectErrorStream (true);
  </code></pre>
  
  <p>prior to the pb.start, with no change.</p>