简体   繁体   English

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

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

I'm having trouble getting Azure Application Logging to work with my Web app. 我无法使Azure应用程序日志记录与我的Web应用程序一起使用。 I can successfully publish and use my web app. 我可以成功发布和使用我的网络应用程序。 When I go to look at the logs, however, the "application" folder is empty. 但是,当我查看日志时,“application”文件夹为空。 I can successfully see messages I write to the console in the stdout.log files... but there's never anything in the application folder. 我可以在stdout.log文件中成功查看我写入控制台的消息......但是应用程序文件夹中从未有过任何内容。

As for what I've tried, I've followed the steps outlined here . 至于我尝试过的,我已经按照这里列出的步骤进行了操作。 It seems pretty straightforward. 看起来很简单。 Configure Azure to turn on Application Logging, write Trace commands in your code, and stuff should get written to the application folder in the logs. 配置Azure以打开应用程序日志记录,在代码中编写跟踪命令,并将内容写入日志中的应用程序文件夹。 I've also tried setting Application Logging (Blob) to on, but I don't see anything written there either. 我也试过设置应用程序日志(Blob),但我也没有看到任何内容。

Below is a screenshot of what I have configured in Azure: 以下是我在Azure中配置的屏幕截图:

Azure截图

And here's an example of me writing to Trace in code: 这是我在代码中写入Trace的一个例子:

public class HomeController : Controller
{
    public IActionResult Index()
    {
        Trace.TraceInformation("At Home");
        return View();
    }
}

This is using ASP.NET 5/MVC 6. Note that I've tried using TraceWarning and TraceError too without luck. 这是使用ASP.NET 5 / MVC 6.请注意,我已经尝试过使用TraceWarning和TraceError,但没有运气。 I've also tried turning on ALL the logging options in Azure, but that doesn't seem to do anything either. 我也尝试在Azure中启用所有日志记录选项,但这似乎也没有做任何事情。

Trace looging doesn't work on Azure with ASP.NET 5. This is known bug 跟踪looging在使用ASP.NET 5的Azure上不起作用。 这是已知的错误

You can use HttpPlatformHandler logging into file system. 您可以使用HttpPlatformHandler登录到文件系统。

Put into your wwwroot directory web.config file: 放入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>

Settings for loogging located here: 这里的懒人设置:

      stdoutLogEnabled="true"
      stdoutLogFile="..\..\LogFiles\httpplatform\httpplatform-stdout.log"

Make sure that direcotory for logging exists in you file system at Azure. 确保Azure中的文件系统中存在用于日志记录的目录。

You have to use standart logging mechanism for write logs 您必须使用标准日志记录机制来写入日志

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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