Skip to content

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

License

Notifications You must be signed in to change notification settings

destructurama/by-ignoring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Destructurama.ByIgnoring

License

codecov Nuget Nuget

GitHub Release Date GitHub commits since latest release (by date) Size

GitHub contributors Activity Activity Activity

Run unit tests Publish preview to GitHub registry Publish release to Nuget registry CodeQL analysis

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

Installation

Install from NuGet:

Install-Package Destructurama.ByIgnoring

Usage

Mark properties to ignore on target types:

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

Mark properties to ignore on assignable types:

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

When these types are destructured, all instance (that is not static) 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"  }`

Benchmarks

The results are available here.

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages