首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我们在azure- iot -edge上有应用程序,并使用azure-iot-sdk连接到iot集线器,但我找不到一种方法来启用azure-iot-sdk的日志?

我们在azure- iot -edge上有应用程序,并使用azure-iot-sdk连接到iot集线器,但我找不到一种方法来启用azure-iot-sdk的日志?
EN

Stack Overflow用户
提问于 2021-05-06 22:05:09
回答 1查看 17关注 0票数 0

我正在使用azure-iot-sdk-csharp,并且我正在运行我的位置。我看到已经有一些日志语句了,这是由DotNetty.Handlers.Logging编写的,整个应用程序将被部署为docker镜像,我不会在docker日志中看到日志。

代码语言:javascript
复制
internal sealed partial class Logging : EventSource
{
    /// <summary>The single event source instance to use for all logging.</summary>
    public static readonly Logging Log = new Logging();
    public static new bool IsEnabled => Log.IsEnabled();

    #region Metadata

    public static class Keywords
    {
        public const EventKeywords Default = (EventKeywords)0x0001;
        public const EventKeywords Debug = (EventKeywords)0x0002;
        public const EventKeywords EnterExit = (EventKeywords)0x0004;
    }
   
    [NonEvent]
    public static void Info(object thisOrContextObject, FormattableString formattableString = null, [CallerMemberName] string memberName = null)
    {
        if (IsEnabled)
        {
            DebugValidateArg(thisOrContextObject);
            DebugValidateArg(formattableString);

            Log.Info(IdOf(thisOrContextObject), memberName, formattableString != null ? Format(formattableString) : NoParameters);
        }
    }
}

有谁知道如何启用日志吗?

EN

回答 1

Stack Overflow用户

发布于 2021-06-23 22:40:56

要在azure-iot-sdk-csharp中捕获日志,可以按照此处的说明进行操作:https://github.com/Azure/azure-iot-sdk-csharp/tree/master/tools/CaptureLogs

控制台日志记录示例:

  1. e2e\test\Helpers\ConsoleEventListener.cs添加到项目中。

  1. 实例化监听程序。添加一个或多个筛选器(例如Microsoft-Azure-DotNetty-):

ConsoleEventListener("Microsoft-Azure-");只读ConsoleEventListener _listener =新私有

  1. 请参见ConsoleEventListener.cs文件以启用Visual Studio代码中的彩色日志。
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67419786

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档