问题
How do you capture startup errors in an ASP.NET Core app hosted in IIS? I'm trying to capture exceptions thrown in ConfigureServices which occurs only in the IIS hosted environment.
I came across this as a certificate file loaded in ConfigureServices was missing and it was not captured without writing to a different log file than the application log file configured through log configuration (note that the logging system doesn't get initialised before ConfigureServices). In this case stderr would contain the exception but does IIS capture it and log it somewhere?
回答1:
ASP.NET Core module for IIS has stdoutLogEnabled and stdoutLogFile optional parameters:
<aspNetCore processPath="dotnet"
arguments=".\MyApp.dll"
stdoutLogEnabled="true"
stdoutLogFile=".\logs\stdout" />
来源:https://stackoverflow.com/questions/49643054/asp-net-core-running-in-iis-startup-error-logging