5

is there a simple way to add ThreadId and ProcessId into the logs through Microsoft.Extensions.Logging without writing my own LoggingProvider?

Simply following code

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

should produce the following or similar output. (please assume I'm talking about 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
Steven
  • 166,672
  • 24
  • 332
  • 435
cilerler
  • 9,010
  • 10
  • 56
  • 91
  • [Serilog – Add thread (and process) ID to the log file](https://briancaos.wordpress.com/2019/02/22/serilog-add-thread-id-to-the-log-file/) –  May 19 '21 at 08:26

1 Answers1

3

Nope, there's nothing built into for the console logger.

davidfowl
  • 37,120
  • 7
  • 93
  • 103