在WF4中跟踪不起作用?

时间:2012-01-08 19:26:14

标签: workflow-foundation workflow-foundation-4

我正在尝试设置一个简单的测试用例,推送到WF4中的TraceListener。我已经创建了一个空的wcf服务库应用程序(只是默认的get / reply xamlx)并将以下内容添加到配置中。我没有记录回来。还有其他需要吗?

<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 个答案:

答案 0 :(得分:3)

这应该有效:

<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>