Closed ailn closed 10 years ago
Btw, having configure additional data like in my previous message and having Message = "For loop iteration {0} with {1}", if you use SLAB's ObservableEventListener like this:
var listener1 = new ObservableEventListener(); listener1.EnableEvents(MyEvents.Log as EventSource, EventLevel.LogAlways, Keywords.All);
var subscr = listener1.LogToFlatFile(@"C:\work\Log.txt");
then you get something like this in the log file: Payload : [index : 1] [message : An error occurred when writing to a listener.]
If I use PerfView with the listener turned on I get: For loop iteration
Yes, normally the context just shows up in the payload, but if you want to also add it to your message, you have to specify the additional replacement parameter. ESP will always add the context at the end after the last parameter on the method call.
As for the SLAB error, I'll have to debug that. Which nuget package contains the ObservableEventListener?
"you have to specify the additional replacement parameter" I did but in PerfView the order was mixed - the context was placed first in the message.
You can download the SLAB package from here: http://www.nuget.org/packages/EnterpriseLibrary.SemanticLogging/
BTW, does ESP always generate _Faulted and _Completed events for interfaces even if I decorate methods with EventAttribute?
See issue #11 and EventSourceImplementation.ImplementComplementMethods.
"I did but in PerfView the order was mixed - the context was placed first in the message."
OIC. Whoops. :)
I fixed the way mapped parameters are added. Now they are all added in the order they are specified in the method, with the context parameter being last.
In v2.0.2.
Thank you Jon!
If you define an event method like this:
[Event(1, Message = "For loop iteration {0}")] void ForLoopIteration(int index);
and add additional context like this:
TraceParameterProvider.Default .ForAnything() .AddContext("arg2", () => "extra");
then in your logs you'll get: "For loop iteration extra''
If Message = "For loop iteration {0} with {1}" then you'll get: "For loop iteration extra with 1"
I guess additional parameters should be added to the end.