[英]Logging from ASP.NET 5 application hosted as Azure Web App
[英]Azure Application Logging not working for my Web App
我無法使Azure應用程序日志記錄與我的Web應用程序一起使用。 我可以成功發布和使用我的網絡應用程序。 但是,當我查看日志時,“application”文件夾為空。 我可以在stdout.log文件中成功查看我寫入控制台的消息......但是應用程序文件夾中從未有過任何內容。
至於我嘗試過的,我已經按照這里列出的步驟進行了操作。 看起來很簡單。 配置Azure以打開應用程序日志記錄,在代碼中編寫跟蹤命令,並將內容寫入日志中的應用程序文件夾。 我也試過設置應用程序日志(Blob),但我也沒有看到任何內容。
以下是我在Azure中配置的屏幕截圖:
這是我在代碼中寫入Trace的一個例子:
public class HomeController : Controller
{
public IActionResult Index()
{
Trace.TraceInformation("At Home");
return View();
}
}
這是使用ASP.NET 5 / MVC 6.請注意,我已經嘗試過使用TraceWarning和TraceError,但沒有運氣。 我也嘗試在Azure中啟用所有日志記錄選項,但這似乎也沒有做任何事情。
跟蹤looging在使用ASP.NET 5的Azure上不起作用。 這是已知的錯誤
您可以使用HttpPlatformHandler登錄到文件系統。
放入wwwroot目錄web.config文件:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<customErrors mode="Off" />
</system.web>
<system.webServer>
<handlers>
<add
name="httpPlatformHandler"
path="*"
verb="*"
modules="httpPlatformHandler"
resourceType="Unspecified"/>
</handlers>
<httpPlatform
processPath="%DNX_PATH%"
arguments="%DNX_ARGS%"
stdoutLogEnabled="true"
stdoutLogFile="..\..\LogFiles\httpplatform\httpplatform-stdout.log"
startupTimeLimit="3600"/>
</system.webServer>
</configuration>
這里的懶人設置:
stdoutLogEnabled="true"
stdoutLogFile="..\..\LogFiles\httpplatform\httpplatform-stdout.log"
確保Azure中的文件系統中存在用於日志記錄的目錄。
您必須使用標准日志記錄機制來寫入日志
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.