3
 public Startup(IHostingEnvironment env)
        {
            Log.Logger = new LoggerConfiguration()
            .MinimumLevel
            .Error()
            .WriteTo.RollingFile("logs\\log-{Date}.txt", LogEventLevel.Information) // Uncomment if logging required on text file
            .CreateLogger();
...........

With above configuration I can see any errors I log in application in logs folder, but only when I run it locally.

However when I deploy the same website on IIS, even logs directory exist in website root level, it doesn't even create file or write any logs to any text file.

Note: logs is the same folder which I have configured in web.config for stderror output and the file is created for stdoutput though:

web.config:

<aspNetCore processPath="dotnet" arguments=".\MyApp.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />

So it cannot be write permissions issue as stdout file is created, but serilog fails to crate file/log errors for some reason.

Nexus23
  • 6,195
  • 9
  • 50
  • 67
  • 2
    Try to use absolute file path to check if it in fact wrote to another folder. – Lex Li Dec 27 '16 at 07:59
  • Relative paths dont work. http://stackoverflow.com/questions/26572225/serilog-in-windows-service-not-writing-to-logfile – crthompson Mar 27 '17 at 20:03
  • Possible duplicate of [Serilog in Windows-Service not writing to logfile](http://stackoverflow.com/questions/26572225/serilog-in-windows-service-not-writing-to-logfile) – crthompson Mar 27 '17 at 20:03
  • Experiencing the same issue with an absolute path to the application's deployed directory – Levi Fuller Apr 21 '17 at 21:23

0 Answers0