1 year ago
#260495
Robert
Mask an exception details delivered through a serilog message
Issue on github that I firstly made: https://github.com/serilog/serilog/issues/1657
I've got such configuration:
loggerConfiguration
.Enrich.FromLogContext()
.Enrich.WithEnvironmentName()
.Enrich.WithMachineName()
.Enrich.WithEnvironmentUserName()
.Enrich.WithSensitiveDataMasking(MaskingMode.Globally, maskingOperators)
.Destructure.With(new MaskingOperatorsDestructuringPolicy(maskingOperators));
and asserts in my logging test:
var testException = new Exception($"{name}: {value}", new Exception($"Inner exception: {name}: {value}"))
{
Data = {{name, value}}
};
_logger.Information($"{name}: {value}");
_logger.Information(value);
_logger.Information($"{value}: {name}");
_logger.Information("{Name}: {Value}", name, value);
_logger.Information("{@ResultObject}", new { name, value });
_logger.Information("{@ResultDictionary}", new Dictionary<string, object>() { { name, value } });
_logger.Information("{@ResultCollection}", new[] { name, value });
_logger.Information(testException, "Throws an exception with sensitive data");
name is a property name
value is a sensitive data that is covered either with sensitive data masking from Serilog.Enrichers.Sensitive
or from my custom masking operators destructuring policy.
All situations are covered except the case when we have exception. Data delivered in this thing should be masked as well, shouldn't it? Do you know how to do it? I would like to make it working for all sinks.
c#
logging
serilog
data-masking
0 Answers
Your Answer