繁体   English   中英

Azure应用程序日志记录不适用于我的Web App

[英]Azure Application Logging not working for my Web App

我无法使Azure应用程序日志记录与我的Web应用程序一起使用。 我可以成功发布和使用我的网络应用程序。 但是,当我查看日志时,“application”文件夹为空。 我可以在stdout.log文件中成功查看我写入控制台的消息......但是应用程序文件夹中从未有过任何内容。

至于我尝试过的,我已经按照这里列出的步骤进行了操作。 看起来很简单。 配置Azure以打开应用程序日志记录,在代码中编写跟踪命令,并将内容写入日志中的应用程序文件夹。 我也试过设置应用程序日志(Blob),但我也没有看到任何内容。

以下是我在Azure中配置的屏幕截图:

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM