title: Using serilog in a class library referenced by other projects
body: <p>I have a solution containing multiple .NET Core API and windows services. How can I integrate Serilog in such a way that I will not be required to make changes at several different places for adding a column or changing some property?</p>
  <p>I'm thinking of adding Serilog in a common library and use that custom library in all other projects however how to invoke starting point of the serilog as we see in below code in Program.cs, any code reference will help.</p>
  <pre><code> .UseSerilog((hostingContext, loggerConfiguration) =&gt;
                  {
                      loggerConfiguration.MinimumLevel.Debug()
                              .MinimumLevel.Override(&quot;Microsoft&quot;, LogEventLevel.Information)
                              .Enrich.FromLogContext()
                              .WriteTo.File(path: Path.Combine(Environment.CurrentDirectory, &quot;Logs&quot;, &quot;log.txt&quot;),
                                  rollOnFileSizeLimit: true,
                                  retainedFileCountLimit: 20,
                                  rollingInterval: RollingInterval.Day,
                                  fileSizeLimitBytes: 10000
                                  )
                              .WriteTo.Console();
                  })
  </code></pre>
  <p>================ Updated ===================</p>
  <pre><code>For windows service, I have the code in common library.
  public class LogManager : ILogManager
      {
         public LogManager()
              {
                  Log.Logger = new LoggerConfiguration()
                               .MinimumLevel.Verbose()
                               .Enrich.FromLogContext()
                               //  .WriteTo.Console(LogEventLevel.Debug, OutputTemplate, theme: AnsiConsoleTheme.Code)
                               .WriteTo.RollingFile(@&quot;C:\Users\hnq6ww\Documents\Important\logs.txt&quot;,
                                                          LogEventLevel.Verbose,
                                                          // OutputTemplate,
                                                          retainedFileCountLimit: (int?)RollingInterval.Day,
                                                          buffered: true, fileSizeLimitBytes: 10000)
                               .CreateLogger();
              }
  }
  </code></pre>
  <p>In Program.cs</p>
  <pre><code>  static void Main(string[] args)
          {
              ILogManager log = new LogManager();
              log.WriteLog(Serilog.Events.LogEventLevel.Information, &quot;Testing&quot;);
          }
  </code></pre>