我正在使用azure-iot-sdk-csharp,并且我正在运行我的位置。我看到已经有一些日志语句了,这是由DotNetty.Handlers.Logging编写的,整个应用程序将被部署为docker镜像,我不会在docker日志中看到日志。
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);
}
}
}有谁知道如何启用日志吗?
发布于 2021-06-23 22:40:56
要在azure-iot-sdk-csharp中捕获日志,可以按照此处的说明进行操作:https://github.com/Azure/azure-iot-sdk-csharp/tree/master/tools/CaptureLogs
控制台日志记录示例:
e2e\test\Helpers\ConsoleEventListener.cs添加到项目中。Microsoft-Azure-或DotNetty-):ConsoleEventListener("Microsoft-Azure-");只读ConsoleEventListener _listener =新私有
ConsoleEventListener.cs文件以启用Visual Studio代码中的彩色日志。https://stackoverflow.com/questions/67419786
复制相似问题