mthamil / by-ignoring

Specify how complex types are logged to Serilog by excluding individual properties.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Destructurama.ByIgnoring

Build status

Specify how complex types are logged to Serilog by excluding individual properties.

Install from NuGet:

Install-Package Destructurama.ByIgnoring

Mark properties to ignore on target types:

Log.Logger = new LoggerConfiguration()
    .Destructure.ByIgnoringProperties<User>(u => u.Password)
    // Other logger configurationg
    .CreateLogger()

When these types are destructured, all properties except the specified ones will be passed through:

Log.Information("Logged on {@User}", new User { Username = "nick", Password = "This is ignored" });

// Prints `Logged on User { Username: "nick"  }`

About

Specify how complex types are logged to Serilog by excluding individual properties.

License:Apache License 2.0


Languages

Language:C# 88.4%Language:PowerShell 11.6%