您的位置:首页 > 移动开发

【Azure 应用服务】通过 Web.config 开启 dotnet 应用的 stdoutLog 日志,查看App Service 产生500错误的原因

2022-02-08 20:09 896 查看

问题描述

Web App(App Service) 经常出现500错误,但是通过高级管理工具(Kudu站点)查看了所有的日志,均没有定位到具体的原因,有那些方式可以查看到更多的信息呢?

 

问题解答

HTTP 500 错误通常表明应用程序代码问题, 应用程序代码中的未处理异常或应用程序中的错误通常是导致此错误的原因。如果为 App Service开启应用服务日志来查看相应的异常信息是非常有帮助的。而如是 .Net 应用,也可以通过web.config 来开启 stdoutLogEnabled,即可以在日志中查看到未捕获的异常信息。 

 

web.config内容如下

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!-- To customize the asp.net core module uncomment and edit the following section.
For more info see https://go.microsoft.com/fwlink/?linkid=838655 -->
<system.webServer>
<!--<httpProtocol>
<customHeaders>
<clear />
<add name="Cache-Control" value="no-cache" />
</customHeaders>

</httpProtocol>-->
<handlers>
<remove name="aspNetCore" />
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\NetCoreWebAPI.dll" stdoutLogEnabled="true" stdoutLogFile="\\?\%home%\LogFiles\stdout">
<environmentVariables />
</aspNetCore>
</system.webServer>
</configuration>

效果如下:

 

 

 

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐