Skip to content

Latest commit

 

History

History
34 lines (24 loc) · 714 Bytes

File metadata and controls

34 lines (24 loc) · 714 Bytes

Complex objects with default ToString() implementation probably need to be destructured

Noncompliant Code Example:

class User
{
    public int Age { get; set; }
}

...

Log.Information("The user is {MyUser}", new User());

Compliant Solution:

class User
{
    public int Age { get; set; }
}

...

Log.Information("The user is {@MyUser}", new User());

// or

Log.Information("The user is {$MyUser}", new User());

Also applies to custom logging wrappers.

Does not apply to ZLogger 2.x interpolated templates: destructuring is Serilog syntax, ZLogger serializes a value with the :json format specifier instead.