Skip to content

About

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

Resources

Stars

44 stars

Watchers

4 watching

Forks

Latest commit

 

History

191 Commits

Folders and files

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

Stars

44 stars

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages