title: ServiceStack 4.5 configure log4net programmatically
body: <p>I am starting a new project with ServiceStack 4.5. Is there any way to configure log4net programmatically? In the documentation I found</p>
  
  <pre><code>LogManager.LogFactory = new Log4NetFactory(configureLog4Net: true); 
  </code></pre>
  
  <p>I added this to the constructor of the AppHost class. However this seems to assume that you put the configuration to the App.config file (I am doing self-hosting on a windows service).</p>
  
  <p>In some other projects I wrote a singleton and then used the Log4Net API to do the configuration:</p>
  
  <pre><code>   private static void CreateFileAppender(ref Logger bedInventoryLogger, string logFilePath, Level logLevel, int maxFileSizeInMb, bool filterNh)
      {
          var filePatternLayout = new PatternLayout
          {
              ConversionPattern = "%date; [%thread]; %-5level; %logger; [%type{1}.%method]; - %message%newline"
          };
          filePatternLayout.ActivateOptions();
          var bediLogFileAppender = new RollingFileAppender
          {
              File = logFilePath,
              AppendToFile = true,
              MaximumFileSize = $"{maxFileSizeInMb}MB",
              MaxSizeRollBackups = 5,
              RollingStyle = RollingFileAppender.RollingMode.Size,
              LockingModel = new FileAppender.MinimalLock(),
              Layout = filePatternLayout,
              StaticLogFileName = true,
              Threshold = logLevel
          };
          if (filterNh)
          {
              bediLogFileAppender.AddFilter(new LoggerMatchFilter
              {
                  LoggerToMatch = "NHibernate",
                  AcceptOnMatch = false
              });
              bediLogFileAppender.AddFilter(new LoggerMatchFilter
              {
                  LoggerToMatch = "NHibernate.SQL",
                  AcceptOnMatch = false
              });
              bediLogFileAppender.AddFilter(new LoggerMatchFilter
              {
                  LoggerToMatch = "FluentNHibernate",
                  AcceptOnMatch = false
              });
          }
          bediLogFileAppender.ActivateOptions();
          bedInventoryLogger.AddAppender(bediLogFileAppender);
      }
  </code></pre>
  
  <p>Since I used several logs, appenders etd and wanted to turn off NHibernate logging (I am using NHibernate 4 as ORM) etc. I found it more convenient to do configuration in C# than in XML.</p>
  
  <p>Is it possible to hook this in with ServiceStack or do I better use Log4Net directly?</p>