ILogger not returning Message and Object in JSON format

4.4k Views Asked by At

Im trying to use ILogger the following way,

_logger.LogInformation("Logging info {someClass}", someClass);

But the output is just the object name.

What am I doing wrong here ?

1

There are 1 best solutions below

1
On

You probably like to destruct the class into properties.

That is opt-in, and can be enabled by using the @

So

_logger.LogInformation("Logging info {@someClass}", someClass);

See also: How to use structured logging and the Message templates specs