问题
I'm trying to set up a simple test case of pushing to a TraceListener in WF4. I've created an empty wcf service library app (just the default get/reply xamlx) and added the below to the config. I get no logging back. Is there something else required?
<system.diagnostics>
<sources>
<source name="System.Workflow">
<listeners>
<add name="System.Workflow" />
</listeners>
</source>
<source name="System.Workflow.Runtime">
<listeners>
<add name="System.Workflow" />
</listeners>
</source>
<source name="System.Workflow.Runtime.Hosting">
<listeners>
<add name="System.Workflow" />
</listeners>
</source>
<source name="System.Workflow.Runtime.Tracking">
<listeners>
<add name="System.Workflow" />
</listeners>
</source>
<source name="System.Workflow.Activities">
<listeners>
<add name="System.Workflow" />
</listeners>
</source>
</sources>
<sharedListeners>
<add name="System.Workflow"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="c:\System.Workflow.trace.log"
traceOutputOptions="DateTime" />
</sharedListeners>
<switches>
<add name="System.Workflow.Runtime" value="Verbose" />
<add name="System.Workflow.Runtime.Hosting" 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" />
</switches>
</system.diagnostics>
回答1:
This should work:
<system.diagnostics>
<sources>
<source name="System.Activities" switchValue="Verbose">
<listeners>
<add name="textListener" />
</listeners>
</source>
</sources>
<sharedListeners>
<add name="textListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="E:\WORK\POC\MyTraceLog.txt"
traceOutputOptions="ProcessId, DateTime" />
</sharedListeners>
<trace autoflush="true" indentsize="4">
<listeners>
<add name="textListener" />
</listeners>
</trace>
</system.diagnostics>
来源:https://stackoverflow.com/questions/8780495/tracing-in-wf4-doesnt-work