gpt4 book ai didi

c# - 如何将 ThreadId 和 ProcessId 添加到每个条目的日志输出中

转载 作者:行者123 更新时间:2023-11-30 23:18:57 24 4
gpt4 key购买 nike

有没有一种简单的方法可以通过 Microsoft.Extensions.LoggingThreadIdProcessId 添加到日志中,而无需编写我自己的 LoggingProvider?

只需遵循代码

Logger.LogInformation("This is a test of the emergency broadcast system.");

应该产生以下或类似的输出。 (请假设我在谈论 ConsoleLogger)

info: [{ProcessId}:{ThreadId}] This is a test of the emergency broadcast system.
  • For those who are familiar with serilog, I'm looking for the features called output template and defining global property
  • Please do not suggest any third party library

最佳答案

不,控制台记录器没有内置任何内容。

关于c# - 如何将 ThreadId 和 ProcessId 添加到每个条目的日志输出中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40537721/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com