Closed benfoster closed 4 years ago
Thanks for the PR, this is an interesting scenario. I need to give this one a bit of thought :+1:
(Sorry, wrong window)
Alternatively a way to provide multiple result properties (not enrichers) would work for us here.
Thanks for the info. I was wondering about something like:
op.AddProperty("Foo", foo);
I.e. add multiple properties to be attached to the operation throughout, perhaps allowing various bits and pieces of data to be collected.
Yes this would would work well. FWIW, I wish Serilog had a similar API. I think it's a little confusing that you call ForContext
to set the Source Context and use the same method to add properties/enrichers.
:+1: yes, it's a bit awkward, I'm hopeful a better pattern will emerge as well.
Any further thoughts on this @nblumhardt?
Sorry Ben, has been a busy couple of weeks :-)
I think we could do the AddProperty(string, object, bool = false)
API. Sounds like a way to move it forward?
sounds good - would you like me to implement. Also are you happy for me to make this chainable i.e. .AddProperty(...).AddProperty(...)
?
Hi Ben - an implementation would be really great, thanks. I'm okay with making it chainable - happy to go with whatever you prefer.
Cheers, Nick
Hey Ben! Hope all is well in your neck of the woods. I just stumbled across this one, I think it's stale now, so closing, but let me know if you want to pick it up again in the future :-) .. Cheers!
Ref #8.
This update allows one or more
LogEventEnricher
instances to be passed toOperation.Complete
in order to enrich the final log event.An example of where this can be used is logging the input parameters and response content in a Web API action filter.
During
ActionExecuting
we begin the operation and enrich it with properties from the input parameters. It is then stored inHttpRequestMessage.Properties
.During
ActionExecuted
we obtain theOperation
and callComplete
enriching it with properties fromHttpResponseMessage.Content
.