title: log4net: different logs on different file appenders at runtime
body: <p>Good morning guys.</p>
  
  <p>I wrote a single istance C# 2.0 app (call it <em>myapp</em>).<br>
  Myapp is called many times, and at every call generates a sort of "task" that will be executed in a separated thread.<br>
  If you call myapp several times in a short time, task are executed in parallel.</p>
  
  <p>Generally I use log4net for logging purposes; I configure it loading an xml file by <code>XmlConfigurator.Configure(&lt;config&gt;.xml)</code> at startup, then I use static <code>LogManager.GetLogger(name)</code> in every class I need a logger, quite simple.</p>
  
  <p>This scenario is challenging, instead.
  I need to do is this: based on one of the args received on every call (call it <em>arg</em>), I need to get a different <em>RollingFileAppender</em> that logs in a different file, e. g. .log.</p>
  
  <p>Just to make an example:</p>
  
  <p>1st call: <code>myapp.exe -arg:01</code><br>
   - myapp creates thread1<br>
   - set a new RollingFileAppender to 01.log file, if not exists<br>
   - objects used in this thread must log in 01.log file </p>
  
  <p>2nd call: <code>myapp.exe -arg:02</code><br>
   - create thread2<br>
   - set a new RollingFileAppender to 02.log file, if not exists<br>
   - objects used in this thread must log in 02.log file, <strong>but not in log.01</strong>  </p>
  
  <p>3rd call: <code>myapp.exe -arg:01</code><br>
   - create thread03<br>
   - get the RollingFileAppender to 01.log file (<strong>it already exists!</strong>)<br>
   - objects used in this thread must log in 01.log file, <strong>but not in log.02</strong>  </p>
  
  <p>And so on.
  I don't need to leave the configuration of RollingAppender in xml file, I can create it programmatically; my idea is to use a static wrapper class, call it LogHelper, that creates appenders if they do not exist based on <em>arg</em>, and that dispatch right ILog istances when needed by objects (in classes I would use something like <code>ILog log = LogHelper.GetLogger(name, arg</code>) to get a logger to use instead o default log4net method <code>LogManager.GetLogger(name)</code>).
  So if I have 2 istances of the same class in 2 different threads, when I log messages goes one per file, depending or <em>arg</em> (I will inject <em>arg</em> in every object, if needed).</p>
  
  <p>I browse many threads here in StackOverflow, but I can't find a solution.</p>
  
  <p>Can someone point me to the right direction?</p>
  
  <p>Thanks in advance.</p>