If I use newly introduced InProcess
hosting model in ASP.NET Core 2.2
as follows:
```
`Serilog` does not write log to file. but if I remove `<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>` from `.csproj` everything works as expected.
My `Serilog` configuration in the Program class as follows:
public static void Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Information() // Set the minimun log level
.WriteTo.File("Logs\log-.txt", rollingInterval: RollingInterval.Day, retainedFileCountLimit: 7) // this is for logging into file system
.CreateLogger();
try
{
Log.Information("Starting web host");
CreateWebHostBuilder(args).Build().Run();
}
catch (Exception ex)
{
Log.Fatal(ex, "Host terminated unexpectedly");
}
finally
{
Log.CloseAndFlush();
}
}
``
How can make
Serilogworkable while using
InProcess` hosting model?
@TanvirArjel ,Hi. Check the "C:WindowsSystem32inetsrv" directory, since w3wp.exe resides there.
Hi, I am having the same issue. I have checked that directory (the "C:WindowsSystem32inetsrv") and it is not there . When I remove "InProcess" from csproj it works fine. Any recommendations? In the case of the person aboves code, it creates a file (and the logs within the created file) right next to the project where I would expect them to be (this is when the "InProcess" is removed).
I found the answer on a different issue. https://github.com/aspnet/AspNetCore/issues/4206. Also, here is a stackoverflow for an answer. https://stackoverflow.com/questions/53846333/serilog-does-not-write-log-to-file-while-using-inprocess-hosting-model-in-asp-ne
Just incase any one else wanders onto this also. Thanks!
Most helpful comment
I found the answer on a different issue. https://github.com/aspnet/AspNetCore/issues/4206. Also, here is a stackoverflow for an answer. https://stackoverflow.com/questions/53846333/serilog-does-not-write-log-to-file-while-using-inprocess-hosting-model-in-asp-ne
Just incase any one else wanders onto this also. Thanks!