【應用服務 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及錯誤代碼

相關文章
相關標籤/搜索