Serilog: Obfuscate sensitive data when serializing to JSON

Created on 21 Mar 2018  ·  3Comments  ·  Source: serilog/serilog

Is there a way to obfuscate properties when Serilogs prints event logs?

For instance, given an object with a sensitive property "SSN":

var person = new Person{Name = "John Doe", SSN = "1234567890"};
Log.Logger.Information("Person {@person}", person);

I would like to see "SSN" = "**" when the value is serialized or suppressing the property altogether would be fine too.

Most helpful comment

@omora-RA see this, this

All 3 comments

@omora-RA see this, this

@skomis-mm that library worked great. @nblumhardt have you considered making the ignore property destructure policy part of Serilog?

Not at present, though it'd be great in the short term if we could make extensions like these more discoverable. Thanks for the feedback @omora-RA .

Was this page helpful?
0 / 5 - 0 ratings