Reputation: 446
For exmple, I have function doSomething(string a, string b, string c)
. And I want to log function executing. I want do something like this:
Logger.Debug("Method doSomething executed", a, b, c)
to avoid writing parameters in message beacause strings can be very long. This functionality is similar to the .Enrich.WithProperty("PropertyName", Value)
.
But i can't do this in Logger constructor.
Logs writes to SEQ
.
Upvotes: 3
Views: 399
Reputation: 31832
ForContext()
can do this:
var enriched = Log.ForContext("A", a)
.ForContext("B", b)
.ForContext("C", c);
enriched.Debug("Method doSomething executed");
All events logged through enriched
will have the properties A
, B
and C
attached.
Upvotes: 1