title: ServiceStack logging setup
body: <p>I want to get log4net and elmah working. I tried to put the code together in AppHost.cs:</p>
  
  <pre><code>public class AppHost : AppHostBase {
      //Tell ServiceStack the name and where to find your web services
      public AppHost() : base("Backbone.js TODO", typeof(TodoService).Assembly) { }
  
      public override void Configure(Funq.Container container) {
          //...
          //Log4Net 1.2.11
          log4net.Config.XmlConfigurator.Configure(new FileInfo("log4net.config"));
          container.Register(x =&gt; new Log4NetFactory(true));
          //Elmah 
          container.Register(x =&gt; new ElmahLogFactory(container.Resolve&lt;Log4NetFactory&gt;()));
          LogManager.LogFactory = container.Resolve&lt;ElmahLogFactory&gt;();
          container.Register&lt;ILog&gt;(x =&gt; LogManager.GetLogger(GetType())); 
          //...
      }
  </code></pre>
  
  <p>Log4net.config, which is currently just a console logger...</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
      &lt;log4net debug="true"&gt;
    &lt;appender name="TraceAppender" type="log4net.Appender.TraceAppender"&gt;
      &lt;layout type="log4net.Layout.PatternLayout"&gt;
        &lt;conversionPattern value="%method %-5level - %message%newline"/&gt;
      &lt;/layout&gt;
    &lt;/appender&gt;
    &lt;root&gt;
      &lt;level value="DEBUG"/&gt;
      &lt;appender-ref ref="TraceAppender"/&gt;
    &lt;/root&gt;
  &lt;/log4net&gt;
  </code></pre>
  
  <p>Then wherever the logger is required:</p>
  
  <pre><code>ILog Logger {get; set;} //injected by ioc
  //...
  Logger.Info("Print something");
  </code></pre>
  
  <p>The <code>Logger.Info("....");</code> line is called without error, but neither Log4Net nor Elmah is printing any output in my code above. If you have experience setting up log4net or elmah with ServiceStack, could you please point out What I have done wrong? </p>
  
  <hr>
  
  <p>EDIT</p>
  
  <p>Changed the FileInfo to full path, it worked as Stefan Egli suggested!</p>
  
  <p>Or click log4net.config xml file in your project, in Properties box </p>
  
  <p>"Copy to Output -> Copy if newer" </p>
  
  <p>That will do, too.</p>
  
  <p>Then, something like this comes up:</p>
  
  <pre><code>Auto-attach to process '[11308] w3wp.exe' on machine 'Desktop' succeeded.
  //... printing info now ...
  Backbone.Todos.AppHost: Info INFO  - TodoService OnGet 
  //... but then after a coffee break ...
  log4net: Hierarchy: Shutdown called on Hierarchy [log4net-default-repository]
  // ... Oops, no longer printing any log ...
  </code></pre>
  
  <p>It seems like the web app went to shutdown itself after being idle for awhile. Then log4net fails to restart again when I click on the web app ... Any idea how to prevent this?</p>
  
  <hr>
  
  <p>EDIT 2</p>
  
  <p>Switched to NLog, happily ever after...</p>