无法查看我的WCF服务日志

时间:2014-02-12 04:25:17

标签: wcf system.diagnostics

我正在尝试使用web.config文件为我的WCF服务启用日志记录。但是我无法看到任何日志。我究竟做错了什么?

<configuration>   <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />   </appSettings>   <system.web>
    <customErrors mode="Off" />
    <compilation debug="true" />   </system.web>   <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="secureBasicHttpBinding">
          <security mode="TransportWithMessageCredential">
            <message clientCredentialType="UserName"/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
        <behavior name="customUserNamePassword">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceCredentials>
            <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="ServiceImplementation.Authentication.CustomUsernamePasswordValidator,ServiceImplementation"/>
          </serviceCredentials>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service name="ServiceImplementation.PaymentLoggerService" behaviorConfiguration="customUserNamePassword">
        <endpoint address="" binding="basicHttpBinding" contract="ServiceContracts.IPaymentLoggerService" 
                  bindingConfiguration="secureBasicHttpBinding" >
        </endpoint>
      </service>
    </services>
    <diagnostics wmiProviderEnabled="true">
      <messageLogging
           logEntireMessage="true"
           logMalformedMessages="true"
           logMessagesAtServiceLevel="true"
           logMessagesAtTransportLevel="true"
           maxMessagesToLog="3000"
       />
    </diagnostics>   </system.serviceModel>   <system.diagnostics>
    <trace autoflush="true" indentsize="4" />
    <sources>
      <source name="System.ServiceModel"
              switchValue="Information, ActivityTracing"
              propagateActivity="true" >
        <listeners>
          <add name="xml"/>
        </listeners>
      </source>
      <source name="System.ServiceModel.MessageLogging" switchValue="All" >
        <listeners>
          <add name="xml"/>
        </listeners>
      </source>
      <source name="myUserTraceSource"
              switchValue="Information, ActivityTracing">
        <listeners>
          <add name="xml"/>
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add name="xml"
           type="System.Diagnostics.XmlWriterTraceListener"
                 initializeData="D:\logs\Traces.svclog" />
    </sharedListeners>   </system.diagnostics>   <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />   </system.webServer> </configuration>

0 个答案:

没有答案