【问题标题】:Is there a way to hide debug logging of a package in Visual Studio C#?有没有办法在 Visual Studio C# 中隐藏包的调试日志记录?
【发布时间】:2021-10-07 23:41:48
【问题描述】:

我正在编写一个 DotNetCore 3.1 Blazer 服务器端应用程序。所需模块之一是我围绕 OPC Foundation 的 NetStandard 实现编写的 OPC UA 客户端包装 dll。这个包装器不记录任何东西。所有日志记录似乎都是由 OPC 基金会完成的。

我们每秒进行大约 25 次读/写操作。每个操作都会记录这样的数据:

8/2/2021 10:42:03.808 Read Completed. RequestHandle=204, PendingRequestCount=0
8/2/2021 10:42:04.501 Read Called. RequestHandle=208, PendingRequestCount=1
8/2/2021 10:42:04.503 Bytes written: 136

这会向调试日志发送垃圾邮件,原因很明显。

理想情况下,我想让我的 dll 不记录这些操作,但在 Visual Studio 2019 中将它们静音的解决方案就足够了。

【问题讨论】:

    标签: c# visual-studio logging blazor opc-ua


    【解决方案1】:

    您可以通过调用 Utils.SetTraceMask() 来配置 OPCF NetStandard 堆栈正在记录的内容

    Level Value Usage
    None 0x0 Not a useable level for logging itself, just for user to deactivate logging
    All 0x7FFFFFFF Output all messages
    Security 0x200 Basic Messages related to security
    ExternalSystem 0x100 Not used within stack
    StartStop 0x80 Messages related to application initialization or shutdown
    OperationDetail 0x40 Detailed Messages for each operation
    Operation 0x20 Basic Messages for each operation
    ServiceDetail 0x10 Detailed Messages for service calls
    Service 0x8 Basic Messages for service calls
    StackTrace 0x4 Output stack traces
    Information 0x2 Output informational messages
    Error 0x1 Output error messages

    注意:要使用堆栈日志记录,需要调用Utils.SetTraceOutput(Utils.TraceOutput.DebugAndFile)Utils.SetTraceLog(null, false),因为到目前为止,堆栈不支持 TraceOutput.DebugOnly 日志记录和登录到文件是不可用的(打开、修改和关闭每个日志条目的跟踪文件)。

    好消息是团队致力于改进跟踪/日志记录(请参阅UA-.NETStandard#1262

    【讨论】:

      猜你喜欢
      • 2021-12-27
      • 1970-01-01
      • 2012-04-13
      • 2013-05-05
      • 2011-04-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多