title: How to initialize Serilog in Windows Service?
body: <p>I have the following issue.I want to be able to use <code>Serilog</code> inside a windows service and i do not know where it should be initilized:</p>
  
  <p>Currently i initialize it in my <code>Main</code>:</p>
  
  <pre><code>using Serilog;
  
  public static void RunService() {
      Log.Logger = new LoggerConfiguration()
        .WriteTo.RollingFile([some path])
        .CreateLogger();
  
      MyService daemon = new MyService();
      Log.Information("Service initialized")
  
      ServiceBase[] services;
      services = new ServiceBase[] {
          service
      };
      Log.Information("Before running the service");
      ServiceBase.Run(services);
  }
  
  static void Main(string[] args) {
     RunService();
  }
  </code></pre>
  
  <p><strong>Service</strong></p>
  
  <pre><code>public class MyService:ServiceBase{
     protected override void OnSessionChange(SessionChangeDescription changeDescription) {
      Log.Information("session changed");
     } 
     protected override void OnStart(string[] args) {
       Log.Information("Started service");
     }
  }
  </code></pre>
  
  <p>So in order to use <code>Serilog</code> both in the <code>Main</code> that runs the collection of services and inside the target service how is it supposed to be done?</p>