首页 > 解决方案 > C# - 将 System.Diagnostics.Tracing 跟踪导出到文本文件

问题描述

我有一个使用标准 EventSource 进行日志记录的 Service Fabric 群集应用程序。

[EventSource(Name = "SomeName")]
internal sealed class ServiceEventSource : EventSource
{
    public static readonly ServiceEventSource Current = new ServiceEventSource();

[NonEvent]
    public void Message(string message, params object[] args)
    {
        if (this.IsEnabled())
        {
            string finalMessage = string.Format(message, args);
            Message(finalMessage);
        }
    }
}

我的应用程序尚未部署到 Azure,但在我的本地开发集群中运行。如果这提供了以下解决方案,则可以部署它。

我有一些单元测试,当我运行它们时,我想将跟踪导出到文本文件。

我必须与同事一起验证我的单元测试,如果我们将跟踪日志打印在纸上,这对我们来说会容易得多。

无论如何(黑客很好)可以做到这一点?也许我可以连接 Azure 服务并从那里获取数据?

从 Visual Studio 2019 中的诊断查看器复制粘贴一次只能完成 1 行。我有数百个。

有任何想法吗?

标签: c#azureazure-service-fabricsystem.diagnostics

解决方案


推荐阅读