在web.config文件中,将配置添加到configuration节中,重启服务后日志文件将写入到c:\temp\log\log_Traces.svclog

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
<system.diagnostics>
<sources>
    <source name="System.ServiceModel"
            switchValue="Information, ActivityTracing"
            propagateActivity="true">
    <listeners>
        <add name="traceListener"
            type="System.Diagnostics.XmlWriterTraceListener"
            initializeData="c:\temp\log\log_Traces.svclog"  />
    </listeners>
    </source>
</sources>
</system.diagnostics>