Serilog stops writing to file

Viewed 407

I'm using Serilog to log Errors in my WebApi with the following configuration.

private static readonly string LogFileName = System.Web.Hosting.HostingEnvironment.MapPath(@"~/App_Data/Logs/Service.log");

    private static void ConfigureLogging(ContainerBuilder builder)
    {
        var loggerConfig = new LoggerConfiguration()
            .ReadFrom.AppSettings()
            .WriteTo.Console()
            .WriteTo.File(LogFileName != null ? LogFileName : "C:/Temp/Logs/Service.log",
                shared: true,
                rollingInterval: RollingInterval.Day);
        // configure global logger for logging in owin middleware
        Log.Logger = loggerConfig.CreateLogger();
        builder.Register(_ => Log.Logger).As<ILogger>();  }`

With Appsettings

<appSettings>
    <add key="serilog:minimum-level" value="Warning" />
</appSettings>

The problem is, it only logs once. The Service is still alive, I can send more Successful requests. And I also see the requests/errors logged in console. But it doesnt add up in logfile.

BUT if I edit the WebConfig - change from Warning to Verbose then back to Warning, so no real changes - it logs again.

1 Answers
Related