title: Swapping from log4net to Serilog using Common.Logging
body: <p>A solution already exists that uses log4net with Common.Logging, 
  we have decided we want to swap out log4net and swap in Serilog. </p>
  
  <p>In <code>App.config</code></p>
  
  <pre><code>--&lt;factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net1215"&gt;
  ++&lt;factoryAdapter type="Common.Logging.Serilog.SerilogFactoryAdapter, Common.Logging.Serilog"&gt;
  </code></pre>
  
  <p>Seems easy enough, but then as I continued looking through our existing <code>App.config</code> file I came across less obvious areas of transition. </p>
  
  <pre><code>--&lt;section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/&gt;
  ++&lt;section name="serilog" type="Serilog.Configuration.LoggerSettingsConfiguration, serilog"/&gt;&lt;!--Not sure if equivalent--&gt;
  </code></pre>
  
  <p>This change does not seem as obviously right and is really just a shot in the dark. In fact, I'm pretty sure it is wrong.</p>
  
  <p>Then there is the actual config of the rolling file appender: </p>
  
  <pre><code>    &lt;log4net&gt;
      &lt;appender name="LM" type="log4net.Appender.RollingFileAppender"&gt;
        &lt;file type="log4net.Util.PatternString" value="%property{LogFileName}\\Program\Logs\\specificProgram.log" /&gt;
        &lt;param name="RollingStyle" value="Size" /&gt;
        &lt;param name="AppendToFile" value="true" /&gt;
        &lt;param name="MaxSizeRollBackups" value="5" /&gt;
        &lt;param name="MaximumFileSize" value="10MB" /&gt;
        &lt;param name="StaticLogFileName" value="true" /&gt;
        &lt;layout type="log4net.Layout.PatternLayout"&gt;
          &lt;param name="ConversionPattern" value="%d{MM-dd-yy HH:mm:ss.fff} [%thread] %-5p - %c{1} - %m%n" /&gt;
        &lt;/layout&gt;
      &lt;/appender&gt;
      &lt;appender name="QuickLog" type="log4net.Appender.RollingFileAppender"&gt;
        &lt;file type="log4net.Util.PatternString" value="%property{LogFileName}\\Program\Logs\\QuickLog.log" /&gt;
        &lt;param name="RollingStyle" value="Size" /&gt;
        &lt;param name="AppendToFile" value="true" /&gt;
        &lt;param name="MaxSizeRollBackups" value="5" /&gt;
        &lt;param name="MaximumFileSize" value="10MB" /&gt;
        &lt;param name="StaticLogFileName" value="true" /&gt;
        &lt;lockingModel type="log4net.Appender.FileAppender+MinimalLock" /&gt;
        &lt;layout type="log4net.Layout.PatternLayout"&gt;
          &lt;param name="ConversionPattern" value="%d{MM-dd-yy HH:mm:ss.fff} [%thread] %-5p - %c{1} - %m%n" /&gt;
        &lt;/layout&gt;
      &lt;/appender&gt;
      &lt;logger name="LM"&gt;
        &lt;level value="TRACE"/&gt;
        &lt;appender-ref ref="LM"/&gt;
      &lt;/logger&gt;
      &lt;logger name="QuickLog"&gt;
        &lt;level value="TRACE"/&gt;
        &lt;appender-ref ref="QuickLog"/&gt;
      &lt;/logger&gt;
    &lt;/log4net&gt;
  </code></pre>
  
  <p>I couldn't find any blogs or documentation on swapping from log4net to Serilog that use mainly <code>App.config</code> for settings... </p>
  
  <p>In the code behind, we have a pretty simple initialization </p>
  
  <pre><code> if (null == s_logger || null == quick_logger)
          {                
              log4net.GlobalContext.Properties["LogFileName"] = MachineConfiguration.DataPath;
              s_logger = CommonLogging.LogManager.GetLogger("LM");
              quick_logger = CommonLogging.LogManager.GetLogger("QuickLog");
          }
  </code></pre>
  
  <p>Serilog also seems to lack a <code>GlobalContext</code>, or at least I haven't found the equivalent yet looking through the library. </p>
  
  <p>Is there any mapping of <code>App.config</code> changes from log4net to Serilog? or somewhere to look up what the equivalent types or params are between the two libraries? </p>
  
  <p>I know I can't be the first person to do this swap, but I am having trouble finding documentation that matches what we currently have in place. </p>