屏蔽通过 Serilog 消息传递的异常详细信息
我首先在github上提出的问题: https://github.com/serilog/serilog/issues/ 1657
第
loggerConfiguration
.Enrich.FromLogContext()
.Enrich.WithEnvironmentName()
.Enrich.WithMachineName()
.Enrich.WithEnvironmentUserName()
.Enrich.WithSensitiveDataMasking(MaskingMode.Globally, maskingOperators)
.Destructure.With(new MaskingOperatorsDestructuringPolicy(maskingOperators));
1657
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");
章 value 是敏感数据,它被 Serilog.Enrichers.Sensitive
或我的自定义屏蔽运算符解构策略的敏感数据屏蔽所覆盖。
除有例外情况外,所有情况均涵盖在内。这个东西中传递的数据也应该被屏蔽,不是吗?你知道该怎么做吗?我想让它适用于所有水槽。
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(quot;{name}: {value}", new Exception(quot;Inner exception: {name}: {value}"))
{
Data = {{name, value}}
};
_logger.Information(quot;{name}: {value}");
_logger.Information(value);
_logger.Information(quot;{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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论