Asp.net core logging to file is not working on iis server inside inetpub\wwwroot\project folder

2.3k views Asked by At

I have turned on my file logging on asp.net core and works perfectly fine on development. But when I install it on IIS server then it does not produce any log files. I am storing my project into inetpub\wwwroot directory. My logger configuration in startup.cs is like this below:

public void Configure(IApplicationBuilder app, IServiceProvider serviceProvider, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddFile(Path.Combine("\\Logs\\storefront_retail_log_{Date}.txt"), LogLevel.Information);
}

If I change the above path to be any static path outside the inetpub then it will start logging. I can think the above as a permission issue. But I don't have user called IIS_IUSER in my system to allow permission.

Turning on stdoutLogEnabled produces file but not of Logger. I am using Serilog.Extensions.Logging.File to log to file.

I think it will be easier to put log file contained to the project itself. Any suggestion on where to put our log files or fix the permission issue?

Thank you

1

There are 1 answers

6
Stoyan Bukovich On

Is this well typed path inetpu\wwwroot in your explenation or just typo (inetpub)? On Windows with IIS there should be IUSR try to set folders and files permissions granting read, write, modify access. That should do the "trick".

Here is more information on both accounts here

I hope it helps. Let us know.