wcf trace and log config

<configuration>
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing">
        <listeners>
          <add type="System.Diagnostics.DefaultTraceListener" name="Default">
            <filter type="" />
          </add>
          <add name="ServiceModelMessageLoggingListener">
            <filter type="" />
          </add>
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add initializeData="..\..\app_messages.svclog"
          type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
          name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
        <filter type="" />
      </add>
    </sharedListeners>
  </system.diagnostics>

  <system.serviceModel>
    <diagnostics>
      <messageLogging logEntireMessage="true"
                      logMessagesAtServiceLevel="true" />
    </diagnostics>
    <bindings>
      <basicHttpBinding>
                <binding name="Basic" closeTimeout="00:01:00" openTimeout="00:01:00"
                    receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
                    bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="None">
                        <transport clientCredentialType="None" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:8090/service/basic" binding="basicHttpBinding"
                bindingConfiguration="Basic" contract="Contracts.IArithmetic" name="Basic" />
        </client>
    </system.serviceModel>
</configuration>

 

 

 

 

配置文件如上:在<system.diagnostics>配置节下的<sources>中配置源信息,源信息的name属性值为:System.ServiceModel.MessageLogging,这表明源为在<system.serviceModel>配置节下的<messageLogging>。source 中的 listener可以添加很多种,这里添加了“System.Diagnostics.DefaultTraceListener”和“

System.Diagnostics.XmlWriterTraceListener”。经过这样配置之后,wcf的trace log 将output到"..\..\app_messages.svclog",和默认的窗口。

so easy!!!!

 

 

你可能感兴趣的:(config)