有没有一种简单的方法可以通过 Microsoft.Extensions.Logging 将 ThreadId 和 ProcessId 添加到日志中,而无需编写我自己的 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/