Friday, October 30, 2009

Sharepoint Workflows / ASP.NET - Logging using diagnostic traceing

One of the coolest feature in asp.net is its tracing. Good thing is that it can be utilized in sharepoint as well and provide an easy way for logging inside workflow foundation.
You just need to add following in you sharepoint web.config file

<system.diagnostics>
<switches>
<add name="System.Workflow LogToTraceListeners" value="1" />
<add name="System.Workflow.Runtime.Hosting" value="Verbose" />
<add name="System.Workflow.Runtime" value="Verbose" />
<add name="System.Workflow.Runtime.Tracking" value="Verbose" />
<add name="System.Workflow.Activities" value="Verbose" />
<add name="System.Workflow.Activities.Rules" value="Verbose" />
<add name="[Your namespace]" value="Verbose" />
</switches>
<trace autoflush="true" indentsize="4">
<listeners>
<add name="myListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="c:\Output.log" />
</listeners>
</trace>
</system.diagnostics>

and use following command in your code for sending log to your file for your logging

System.Diagnostics.Trace.WriteLine([message])

No comments:

Post a Comment