title: Log4j2: How to write logs to separate files for each user?
body: <p>Here is the challenge I'm facing:</p>
  
  <p>I have a servlet program. And I need to write logs for each user to the folder named after that user.
  Something like this:</p>
  
  <pre><code>    // stores message to David folder
      // /root_path/David/logfile.log
      logger.error(MarkerManager.getMarker("David"), "Error happened");
  
      // stores message to Mark folder
      // /root_path/Mark/logfile.log                 
      logger.error(MarkerManager.getMarker("Mark"), "Something is broken");
  </code></pre>
  
  <p>In my example I used markers. But I don't really know whether markers appropriate for this task.</p>
  
  <p>In general my appender should behave like RollingRandomAccessFile appender.
  I guess config for appender must look like something like this:</p>
  
  <pre><code>     &lt;RollingRandomAccessFile name="rollingFile"
                   fileName="logs/{markerName ?????}/movie-db.log"
                   filePattern="logs/log-%d{yyyy-MM-dd}-%i.log.zip"
                   append="false"
                   immediateFlush="false"
                   ignoreExceptions="true"&gt;
          &lt;PatternLayout pattern="%d{ISO8601} %level{length=5} [%thread] %logger - %msg%n"/&gt;
          &lt;Policies&gt;
              &lt;SizeBasedTriggeringPolicy size="25 MB"/&gt;
              &lt;TimeBasedTriggeringPolicy /&gt;
          &lt;/Policies&gt;
          &lt;DefaultRolloverStrategy max="10"/&gt;
      &lt;/RollingRandomAccessFile&gt;
  </code></pre>
  
  <p>Any ideas?</p>