Tracing in WF4 doesn't work?

主宰稳场 提交于 2019-12-10 11:11:17

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!