Azure 机器人服务中的跟踪 [英] Trace in Azure Bot Service
问题描述
我正在按照此步骤在 Azure Bot 应用服务中启用跟踪 https://microsoft.github.io/AzureTipsAndTricks/blog/tip30.html
I'm following this step to enable tracing in Azure Bot App Service https://microsoft.github.io/AzureTipsAndTricks/blog/tip30.html
但是,我的跟踪没有出现在日志流中.我可以在这里看到一堆其他日志.
However, my trace does not appear in the log stream. I can see a bunch of other logs here.
我也试过#define TRACE"在课堂上用代码
I also tried "#define TRACE" at the class with the code
System.Diagnostics.Trace.WriteLine("Entering the About View");
我错过了什么吗?
我的 Azure Web 应用设置:https://pictr.com/images/2019/06/25/5BHthA.png
My Azure Web App setting: https://pictr.com/images/2019/06/25/5BHthA.png
我的日志流:https://pictr.com/images/2019/06/25/5BHszI.png
谢谢.
推荐答案
除了在门户中启用它的更改;您需要使用 Microsoft.Extensions.Logging
命名空间.添加 Microsoft.Extensions.Logging.AzureAppServices
包(适合您的项目的版本).
Apart from the changes in the portal to enable it; you'll want to use the Microsoft.Exensions.Logging
namespace. Add the Microsoft.Extensions.Logging.AzureAppServices
package (version appropriate for your project).
然后为设置主机的 azure (AddAzureWebAppDiagnostics
) 添加日志记录:
Then add logging for azure (AddAzureWebAppDiagnostics
) where you setup your host:
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.ConfigureLogging((logging) =>
{
logging.AddAzureWebAppDiagnostics();
});
然后确保您的类实现了 ILogger.您可以在 Core bot 示例 这里.
Then make sure your class implements ILogger. You can see an example of that in the Core bot sample here.
然后用你想要的方法登录:
Then just do your logging in the method you wish:
Logger.LogInformation("This is my test.");
以下是更多信息:https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-2.2
这篇关于Azure 机器人服务中的跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!