title: Configure log4net to write to different log files, no config files
body: <p>I want to do this:</p>
  
  <p><a href="https://stackoverflow.com/questions/1372435/configure-log4net-to-write-to-multiple-files">Configure Log4net to write to multiple files</a></p>
  
  <p>But I want to use code-as-configuration.  How do I do this?</p>
  
  <p>Here's what I've tried:</p>
  
  <pre><code>// Configure log A
  Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();
  
  PatternLayout patternLayout = new PatternLayout();
  patternLayout.ConversionPattern = "%date %level %logger: %message%newline";
  patternLayout.ActivateOptions();
  
  RollingFileAppender appender = new RollingFileAppender();
  appender.Name = @"MyLogA";
  appender.File = @"C:\Temp\MyLogs\A.log";
  appender.AppendToFile = true;
  appender.MaxSizeRollBackups = 2;
  appender.RollingStyle = RollingFileAppender.RollingMode.Size;
  appender.MaximumFileSize = "10MB";
  appender.Layout = patternLayout;
  appender.LockingModel = new FileAppender.MinimalLock();
  appender.StaticLogFileName = true;
  appender.ActivateOptions();
  hierarchy.Root.AddAppender(appender);
  
  hierarchy.Configured = true;
  
  // Configure log B
  Hierarchy hierarchyB = (Hierarchy)LogManager.GetRepository();
  
  PatternLayout patternLayoutB = new PatternLayout();
  patternLayoutB.ConversionPattern = "%date %level %logger: %message%newline";
  patternLayoutB.ActivateOptions();
  
  RollingFileAppender appenderB = new RollingFileAppender();
  appenderB.Name = @"MyLogB";
  appenderB.File = @"C:\Temp\MyLogs\B.log";
  appenderB.AppendToFile = true;
  appenderB.MaxSizeRollBackups = 2;
  appenderB.RollingStyle = RollingFileAppender.RollingMode.Size;
  appenderB.MaximumFileSize = "10MB";
  appenderB.Layout = patternLayout;
  appenderB.LockingModel = new FileAppender.MinimalLock();
  appenderB.StaticLogFileName = true;
  appenderB.ActivateOptions();
  hierarchyB.Root.AddAppender(appenderB);
  
  hierarchyB.Configured = true;
  
  
  // Test Log A
  
  var loggerA = log4net.LogManager.GetLogger("MyLogA");
  
  loggerA.Info("TestA");
  loggerA.Info("TestA");
  loggerA.Info("TestA");
  loggerA.Info("TestA");
  loggerA.Info("TestA");
  
  // Test Log B
  var loggerB = log4net.LogManager.GetLogger("MyLogB");
  loggerB.Info("TestB");
  loggerB.Info("TestB");
  loggerB.Info("TestB");
  loggerB.Info("TestB");
  loggerB.Info("TestB");
  </code></pre>
  
  <p>But when I do this, all ten log messages get dumped into both LogA and LogB, they don't go to their respective individual log files.</p>
  
  <p>How can I get this to work?</p>