WCF Tracing and Message Logging - Trace Level Warning

Suppose I have a configuration file that looks like this: ...                    

<system.diagnostics>
  <sources>
    <source name="System.ServiceModel" switchValue="Warning,ActivityTracing" propagateActivity="true">
      <listeners>
        <add name="ServiceModelTraceListener" />
      </listeners>
    </source>
    <source name="System.ServiceModel.MessageLogging">
      <listeners>
        <add name="ServiceModelTraceListener" />
      </listeners>
    </source>
  </sources>
  <sharedListeners>
    <add initializeData="LogServer.svclog" type="System.Diagnostics.XmlWriterTraceListener" name="ServiceModelTraceListener" />
  </sharedListeners>
  <trace autoflush="true" />
</system.diagnostics>

When using this configuration file, every action that the caller performs against the service and every corresponding message sent to the service will be logged in the svclog file. Everything is still fine.

If I change the third line from the above list to <source name="System.ServiceModel" switchValue="Warning" propagateActivity="true">(is deleted ActivityTracing), only those actions that are at least marked with a level warning are logged. But it is still registered in every message ...

, , , ? , , , , , !

+5
3

Edit , , .

. , , , , , , DEBUG ..

class DB : TraceSource
{
    public DB(string name) : base(name)
    { 
    }

    public DB(string name, SourceLevels sourceLevels) : base (name, sourceLevels)
    { 
    } 

    public void Log(object value)
    {
        WriteLine(value);
    }

    public void Error(object value)
    {
        WriteLine(value, TraceEventType.Error);
    }

    public void Error(RecordingResponseData errorResponse)
    {
        string errorMessage = "[Error] Code: "+errorResponse.ErrorCode +" Message: "+errorResponse.ErrorMessage;
        WriteLine(errorMessage, TraceEventType.Error);
    }

    public void Warn(object value)
    {
        WriteLine(value, TraceEventType.Warning);
    }

    public void WriteLine(object value, TraceEventType type = TraceEventType.Information)
    { 
        TraceEvent(type, 0, value.ToString());
    }


}

:

  • Critical
  • ActivityTracing

. "", - , "" "".

ref: https://msdn.microsoft.com/en-us/library/ms733025%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396

+1

switchValue System.ServiceModel.MessageLogging. source Warning, , .

0

System.ServiceModel.MessageLogging, , " ".

0

All Articles