在IIS中运行的ASP.NET核心启动错误日志记录 [英] ASP.NET core running in IIS startup error logging
问题描述
如何捕获IIS托管的ASP.NET Core应用程序中的启动错误?我正在尝试捕获在ConfigureServices
中引发的异常,该异常仅在IIS托管环境中发生.
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.
我遇到了此问题,因为丢失了ConfigureServices
中加载的证书文件,并且未写入与通过日志配置配置的应用程序日志文件不同的日志文件中,未捕获到该文件(请注意,日志记录系统未初始化) ConfigureServices
之前).在这种情况下,stderr
将包含该异常,但是IIS是否会捕获该异常并将其记录在某个地方?
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?
推荐答案
用于IIS的ASP.NET Core模块具有stdoutLogEnabled
和stdoutLogFile
可选参数:
<aspNetCore processPath="dotnet"
arguments=".\MyApp.dll"
stdoutLogEnabled="true"
stdoutLogFile=".\logs\stdout" />
这篇关于在IIS中运行的ASP.NET核心启动错误日志记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!