When customizing a build definition you will soon discover that the logs may be pretty noise. Even if the activities don’t emit any logging information, just invoking an activity will result in it’s Display Name being logged.
This can be quite verbose, specially when you start nesting activities within containers.
Look at this simple (perhaps a little convoluted example) whereas a simple FTP issues too much information.
Unfortunately there is no way to disable this logging on an activity by activity basis by just using the Workflow Designer, however if you are willing to edit the build XAML in a text editor you can disable the logging by activity.
Suppose you have a sequence activity called Copy Files to FTP and you don’t want it logged
<Sequence DisplayName=”Copy Files to FTP” >
You just need to edit the XAML file and set the attribute BuildTrackingParticipant.Importance __with the minimum level of activity you want to log
So the XAML for this snippet would become
<Sequence DisplayName=”Copy Files to FTP” mtbwt:BuildTrackingParticipant.Importance=”Low”>
You can read all about this on more detail on this Jason’s Pricket post
But this is for activities that you use on the designer, what about code activities that you write, wouldn’t be nice to have make them less noisy when they are invoked, without requiring people to edit the XAML file manually ?
Not only would be nice, but it is also possible to do it. All you need to do is add the
Microsoft.TeamFoundation.Build.Workflow.Tracking.ActivityTracking attribute with the right level of logging.
For example with this snippet, everytime the MyActivity is invoked, the call is never logged on Team Foundation Build
[ActivityTracking(ActivityTrackingOption.None)] [BuildActivity(HostEnvironmentOption.All)] [BuildExtension(HostEnvironmentOption.Agent)] public sealed class MyActivity : CodeActivity
This achieves the same effect as editing the XAML file to add the BuildTrackingParticipant.Importance on all calls to MyActivity
So if you are writing workflow custom activities and the fact that was called appears in the logs doesn’t add any value (for example if are writing a logger or you already log useful information), be a good citizen and add this attribute to reduce the noise.