Serilog not logging in rolling file when deployed to IIS?

See original GitHub issue
 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 screated, but serilog fails to crate file for some reason.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

5reactions
beugnencommented, Jun 18, 2019

FWIW I believe it is general considered “bad practice” to log to files on production environments, because :

  • it requires explicit permissions
  • without proper log-files administration, you might end up filling up the disk
  • it makes it hard to extract information from the logs
  • it makes it hard to analyze logs in “farm” environments (with several servers handling requests)

Utter nonsense. Going by your logic if a system fails no one will ever be able to fix a fault because there is no diagnostic information due to an irrational fear that the hard drive might fill up (which I might add is easily rectified by employing a due-diligent Operations Staff).

I guess someone better tell people not to use:

  • The Windows Event Log
  • MSMQ
  • SQL Server Transaction Log
  • Dynamic Windows Pagefile
3reactions
tsimbalarcommented, Oct 6, 2017

I know that on our production environments, the IIS application pool accounts do not have any write permissions anywhere … (it is a choice from the Ops team)

FWIW I believe it is general considered “bad practice” to log to files on production environments, because :

  • it requires explicit permissions
  • without proper log-files administration, you might end up filling up the disk
  • it makes it hard to extract information from the logs
  • it makes it hard to analyze logs in “farm” environments (with several servers handling requests)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Enable file logging on IIS for serilog - net core
2 Answers. Serilog works perfectly on local. For IIS the log file folder need IIS User Permission. Now give folder permission on deployed...
Read more >
Serilog configured in .Net Core web api not showing up ...
Serilog configured in .Net Core web api not showing up logs under configured path after deploying to IIS in Azure VM. · Open...
Read more >
Logging with Serilog in ASP.NET Core Web API
For this tutorial, we are mainly interesting in File sinks since we will be dumping our logs within rolling files.
Read more >
Setting up Serilog in ASP.NET Core - Detailed Beginner ...
This article covers the implementation of Serilog in ASP.NET Core which provides structured logging that is easier to be read by programs.
Read more >
.NET Logging Basics - The Ultimate Guide To Logging - Loggly
Serilog is an open-source library like the IloggerFactory and can write logs to many different destinations such as files, a console, an Elasticsearch...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found