【应用服务 App Service】App Service发生错误请求时,如何查看IIS Freb日志,从中得知错误所发生的模块,请求中所携带的Header信息

问题描述

在使用Azure App Service时候,咱们有时候对 一些请求发生错误毫无头绪,能从错误代码中知道请求错误,可是更多的信息呢? 当咱们须要更多的信息时候,一般有如下的一些方式来查找问题:jquery

  • 在浏览器中开启开发者模式(F12),查看Network的记录,分析那些请求错误,找出请求Header及Response...
  • 使用Fiddler抓取本机发出的请求记录...
  • 在代码中添加更多的业务日志,查看代码运行到哪一行才出现错误...
  • 使用Postman发送请求,验证是否时请求的Header或Body不匹配...

可是,Azure App Service做为PaaS服务(平台即服务),提供了很是有帮助的错误请求日志 - FREB日志。 如下的内容就介绍如何开启Freb日志如何查看日志,及在日志中能发现有用的信息web

开启FREB日志

进入App Service的App Service logs页面,开启Failed request tracing。浏览器

Failed Request Trackingapp

Detailed information on failed requests including the web server components which were used to process the request and time that was taken to process the request.ide

Detailed Error Messages

If the error code is greater than 400, the app service can store the HTML pages which otherwise would have been sent to the client. These pages can be useful to identify / troubleshoot the error.spa

查看FREB日志

一:登陆Kudu站点 (App Service --> Advanced Tools 页面 --> GO 或者在app Service的URL中添加.scm,如:https://xxxxxxxxxxxx.scm.chinacloudsites.cn)3d

二:进入D:\home\LogFiles\W3SVC开头的目录,选中如错误请求时间点匹配的文件,点击右边的“下载按钮”,FREB日志显示为可阅读格式。日志

:如须要拷贝出去,当须要友好的阅读体验时,也须要在同一目录文件中包含freb.xml文件)code

 

从FREB中分析内容

查看Request在IIS中最终所到达时候的Header信息,是否有缺乏默写敏感的信息,如Authorization。component

查看Request的所经历的Module及错误代码