Serilog WriteTo.RollingFile seems to create 500 error code when I publish to Azure

411 Views Asked by At

I published a basic asp.net core app to Azure experimenting with Serilog but it gives me a 500 error after publishing. When I comment out the RollingFile Sink it publishes fine without error. Any reason why this might be happening? Also it works fine on my local machine.

      public Startup(IHostingEnvironment appEnv)
      {
        Log.Logger = new LoggerConfiguration()
            .MinimumLevel.Information()
          //.WriteTo.RollingFile(Path.Combine(appEnv.WebRootPath, "log-{Date}.txt"), retainedFileCountLimit: 5)              
            .CreateLogger();
      }
1

There are 1 best solutions below

2
On BEST ANSWER

It's possible for env.WebRootPath to be null. In that case, Path.Combine() will (AFAIK) throw an ArgumentNullException, which would account for the 500 errors.