【问题标题】:SvcTraceViewer not showing exceptions in redSvcTraceViewer 未以红色显示异常
【发布时间】:2019-10-03 22:52:59
【问题描述】:

问题是来自我的 Web 服务的异常活动在 SvcTraceViewer 中没有以红色显示。示例:

throw new Exception("No hello to you!");

在 SvcTraceViewer 中显示为(红色的行是关于服务绑定不匹配的。可能是因为我正在使用 WcfTestClient,但它似乎仍然有效):

但根据https://docs.microsoft.com/en-us/dotnet/framework/wcf/service-trace-viewer-tool-svctraceviewer-exe的文档,它应该是红色的

"Activities that contain warning traces have a yellow background 
and those that contain error traces have a red one."

Web.config:

<?xml version="1.0"?>
<configuration>

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5"/>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
        <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>    
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />

    <diagnostics>
      <messageLogging logEntireMessage="true" logMalformedMessages="true"
        logMessagesAtTransportLevel="true" />
    </diagnostics>

  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>
  </system.webServer>

  <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>
      <source propagateActivity="true" name="System.ServiceModel" switchValue="Information,ActivityTracing">
        <listeners>
          <add type="System.Diagnostics.DefaultTraceListener" name="Default">
            <filter type="" />
          </add>
          <add name="ServiceModelTraceListener">
            <filter type="" />
          </add>
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add initializeData="C:\tmp\log\Web_messages.svclog" type="System.Diagnostics.XmlWriterTraceListener"
        name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
        <filter type="" />
      </add>
      <add initializeData="C:\tmp\log\Web_tracelog.svclog" type="System.Diagnostics.XmlWriterTraceListener"
        name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
        <filter type="" />
      </add>
    </sharedListeners>
    <trace autoflush="true" />
  </system.diagnostics>

</configuration>
  • 有什么想法可能是什么问题?
  • 我误解了 文档?

【问题讨论】:

    标签: c# .net wcf logging trace


    【解决方案1】:

    似乎只有部分异常会显示为红色,例如无法连接到远程服务器。

    当我在客户端添加诊断并关闭服务器时,错误将显示在日志中。 但是当我在服务器端抛出异常时,它会生成另一个随机文件名的日志文件。

    以下是自动生成的文件 11360b4c-3ea3-47fa-85d5-12c313bb​​55b4temp.svclog 的快照

    【讨论】:

    • 我只记录服务器端。由于日志文件被锁定,您可能会得到随机文件名。我正在尝试了解 SvcTraceViewer 对普通用户的可用性
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-29
    • 1970-01-01
    • 1970-01-01
    • 2012-07-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多