0

I've currently got some code that looks like this:

_logger.LogInformation("Found a problem {Problem}", Format(problemDetails));

where Format converts ProblemDetails to a string.

I would like to register a handler within the logging framework to explain how this type should be serialized to string so that I could type

_logger.LogInformation("Found a problem {Problem}", problemDetails);

and not just get the result of calling .ToString(). Is this possible?

Julian Birch
  • 2,605
  • 1
  • 21
  • 36

1 Answers1

0

Just add an @ before the Problem. The problemDetails is written as Json:Structured logging

_logger.LogInformation("Found a problem {@Problem}", problemDetails);
Hossein Sabziani
  • 1
  • 2
  • 15
  • 20