0

Application is in .net framework and using Serilog for logging.

Configuration

Logger = new LoggerConfiguration()
    .Enrich.FromLogContext()
    .MinimumLevel.Debug()
    .WriteTo.Console()
    .CreateLogger()

In Unit test how to verify that logger has the values which is expected to be?

Is there any way to read the values using any of Serilog api/methods?

Chris Schaller
  • 13,704
  • 3
  • 43
  • 81
winadi
  • 141
  • 1
  • 6
  • are you seeking to validate that you configured it correctly, or that some app logic wrote the correct log info ? – Ruben Bartelink Dec 17 '19 at 19:12
  • Yes want to check if the configuration is proper And the logs which I'm writing is as expected per the logic I put – winadi Jan 17 '20 at 09:20
  • I would say Serilog can be trusted - it has its own tests, and so can stdout - so, I would not be testing to validate such concerns. (You could run the exe, capture the oiutpiut and verify it includes a message, but again, the value wouldnt be clear to me) – Ruben Bartelink Jan 17 '20 at 09:40

0 Answers0