如何使用svconfigeditor.exe编辑WCF Service配置文件--配置Diagnostics进行WCF Service的log和Trace(三)...

WCF service具备强大的debug和trace功能,本节将介绍WCF service Diagnostic的配置

打开svcconfigeditor后,有关diagnostics的screenshot如下所示:

下面一一介绍:

1.1  performance counter

Specifies whether performance counters for the assembly are enabled. Valid values are

  • Off: Performance counters are disabled.
  • ServiceOnly: Only performance counters relevant to this service is enabled.
  • All: Performance counters can be viewed at runtime.
  • Default: A single performance counter instance _WCF_Admin is created. This instance is used to enable the collection of SQM data for used by the infrastructure. None of the counter values for this instance are updated and therefore will remain at zero. This is the default value if no configuration is present for WCF.

eg.当将其设置为off时, WCf service开始运行时,perfom仍然无法添加其对应的performance couter.当将其设置为ServiceOnly或者All时,即可以看到运行时的该service的相对应的WCF service instance.

如下图所示:

其中,http://yaweiw-64/service  为该服务metadata地址,mymath为该service的一个endpoint. 

1.2 messageLogging

This element defines the settings for the message-logging capabilities of Windows Communication  Foundation (WCF). (详细信息请参阅http://msdn.microsoft.com/en-us/library/ms731308.aspx

如果要对所有service写入log, 那么必须enable messageLogging即可

该配置screenshot如下所示:

messageLogging中相应element和attrible意义如下表所示:

属性 说明

logEntireMessage

一个布尔值,指定是否记录整个消息(消息头和正文)。默认值为 false,这意味着仅记录消息头。此设置会影响所有消息日志记录级别(服务、传输和格式不正确)。

logMalformedMessages

一个布尔值,指定是否记录格式不正确的消息。格式不正确的消息将不计入 maxMessagesToLog。默认值为 false

logMessagesAtServiceLevel

一个布尔值,指定是否在服务级别跟踪消息(在与加密和传输有关的转换之前)。默认值为 false

logMessagesAtTransportLevel

一个布尔值,指定是否在传输级别跟踪消息。配置文件中指定的所有筛选器都会应用,但仅跟踪与这些筛选器相匹配的消息。默认值为 false

maxMessagesToLog

一个正整数,指定要记录的最大消息数。默认值为 1000。

maxSizeOfMessageToLog

一个正整数,指定要记录的最大消息大小(字节)。大小超出限制的消息将不会被记录。此设置会影响所有跟踪级别。默认值为 262144 (0x4000)。

 经过以上配置,当service启动之后,所有访问service都被Log至所指定的文件中。

1.3 Tracing

tracing配置screenshot如下所示:

生成的xml config segment如下所示:

ContractedBlock.gif ExpandedBlockStart.gif Code
<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 name="System.ServiceModel" switchValue="Warning, ActivityTracing"
                propagateActivity
="true">
                
<listeners>
                    
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
                        
<filter type="" />
                    
</add>
                    
<add name="ServiceModelTraceListener">
                        
<filter type="" />
                    
</add>
                
</listeners>
            
</source>
        
</sources>
        
<sharedListeners>
            
<add initializeData="d:\Study\CertificateWCF\CertificateWCF\CertificateWCFService\App_messages.svclog"
                type
="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
                name
="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
                
<filter type="" />
            
</add>
            
<add initializeData="d:\Study\CertificateWCF\CertificateWCF\CertificateWCFService\App_tracelog.svclog"
                type
="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
                name
="ServiceModelTraceListener" traceOutputOptions="Timestamp">
                
<filter type="" />
            
</add>
        
</sharedListeners>
    
</system.diagnostics>

 

转载于:https://www.cnblogs.com/Winston/archive/2008/10/29/1322317.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值