Serilog T Generic Transformer
This package allows to transform object logged in Serilog. You can ignore, mask, rename or write your custom transformer. The package is written to support clean architecture, separating class creation from how it is written.
Install from NuGet:
Install-Package SerliogTTransformer
Modify logger configuration:
var log = new LoggerConfiguration()
.AddTTransformer()
.Destructure.Transform<User>(b => b. ...)
...
public class User
{
public string Username { get; set; }
public string Password { get; set; }
public string Phone { get; set; }
}
var log = new LoggerConfiguration()
.AddTTransformer()
.Destructure.Transform<User>(b => b.Ignore(u => u.Password))
...
var log = new LoggerConfiguration()
.AddTTransformer()
.Destructure.Transform<User>(b => b.Ignore(u => u.Password, 'X'))
...
var log = new LoggerConfiguration()
.AddTTransformer()
.Destructure.Transform<User>(b => b.Ignore(u => u.Phone, 3, 3))
...
var log = new LoggerConfiguration()
.AddTTransformer()
.Destructure.Transform<User>(b => b.Rename(u => u.Username, "Name"))
...
var log = new LoggerConfiguration()
.AddTTransformer()
.Destructure.Transform<User>(b => b.Transform(u => u.Username, new MyCustomerTranformer()))
...