ActivityId not written by FormattedDatabaseTraceListener

Topics: Building and extending application blocks, Logging Application Block
Mar 21, 2007 at 9:20 PM
Hi,

I like to use correlation blocks to group "requests" in an easy way. Lets say I wanna group all the log entries written in nested code to a single group like this:

using(new Tracer("x", {Guid}))
{
PrepareALot();
DoALot();
CleanupALot();
}

each an every LogEntry instance that is created within this block belongs automatically to my ActivityId _> grouping...

But the FormattedDatabaseTraceListener to where I write all my log entries doesn't write the ActivityId, why? That's exactly what I miss now when I wanna track "requests".

Thanks
Mar 22, 2007 at 1:40 AM
Hi Chris -

The schema used by the Database Trace Listener doesn't include a column for ActivityId. If you include a token for it in your formatter you can access this data from the formattedmessage column. However to make it easier to filter and search by ActivityId, you may want to modify the schema and the Trace Listener to include this as a dedicated column.

Tom
Mar 20, 2008 at 5:54 PM
Tom -

ActivityId does not appear to be a valid token for the TextFormatter - it does not appear in the dropdown in the configuration app, nor does it work when I type it in directly. Or are you saying you must create a custom formatter that would work for this? Is this possible?


If not, I'm very tempted to modify the source code, but then I'd be saddled with the continued maintenance of those changes when future versions of Enterprise Library come out. Is there any plan to include this field in future versions? Tracing is one of the most basic uses of logging, can't imagine there wouldn't be a large audience for this.


Thanks!

Andy
Mar 21, 2008 at 3:05 PM
Hi Andy,

You should be able to use the standard property access token for this; the syntax is {property(ActivityId)}.

Fernando