[英]Log properties not recording in Serilog
例如,我有函数doSomething(string a, string b, string c)
。 而且我想记录功能执行情况。 我想做这样的事情:
Logger.Debug("Method doSomething executed", a, b, c)
避免在消息中写入参数,因为字符串可能很长。 此功能类似于.Enrich.WithProperty("PropertyName", Value)
。 但是我无法在Logger构造函数中执行此操作。 日志写入SEQ
。
ForContext()
可以做到这一点:
var enriched = Log.ForContext("A", a)
.ForContext("B", b)
.ForContext("C", c);
enriched.Debug("Method doSomething executed");
通过enriched
记录的所有事件将附加属性A
, B
和C
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.