【问题标题】:Trace in Azure Bot ServiceAzure 机器人服务中的跟踪
【发布时间】:2019-08-17 16:27:07
【问题描述】:

我正在按照此步骤在 Azure Bot App Service https://microsoft.github.io/AzureTipsAndTricks/blog/tip30.html 中启用跟踪

但是,我的跟踪没有出现在日志流中。 我可以在这里看到一堆其他日志。

我还用代码在课堂上尝试了“#define TRACE”

System.Diagnostics.Trace.WriteLine("Entering the About View");

我错过了什么吗?

我的 Azure Web 应用设置:https://pictr.com/images/2019/06/25/5BHthA.png

我的日志流:https://pictr.com/images/2019/06/25/5BHszI.png

谢谢。

【问题讨论】:

    标签: debugging trace azure-bot-service


    【解决方案1】:

    谢谢。如果在https://github.com/martinkearn/Bot-Starter-Template/ 使用 Starter Bot,也可以使用以下命令登录到 App Service 的 Logstream:

      ILogger<BotFrameworkHttpAdapter> logger,
    
     logger.LogError($"Exception caught on attempting to Delete ConversationState : {e.Message}");
    

    【讨论】:

      【解决方案2】:

      除了在门户中启用它的更改;你会想要使用 Microsoft.Exensions.Logging 命名空间。添加Microsoft.Extensions.Logging.AzureAppServices 包(适合您项目的版本)。

      然后在您设置主机的位置为 azure (AddAzureWebAppDiagnostics) 添加日志记录:

          public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
              WebHost.CreateDefaultBuilder(args)
                  .UseStartup<Startup>()
                  .ConfigureLogging((logging) =>
                  {
                      logging.AddAzureWebAppDiagnostics();
                  });
      

      然后确保您的类实现 ILogger。您可以在 Core bot 示例 here 中看到一个示例。

      然后用你想要的方法登录:

      Logger.LogInformation("This is my test.");
      

      这里有更多信息: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-2.2

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-03-31
        • 1970-01-01
        • 2016-01-21
        • 2022-01-19
        相关资源
        最近更新 更多