如何从代码而不是应用程序配置文件启用WCF消息日志记录 [英] How to enable WCF message logging from code instead of the application configuration file

查看:223
本文介绍了如何从代码而不是应用程序配置文件启用WCF消息日志记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用WCF在两个进程之间进行通信。默认情况下,当出现错误时,会产生非常模糊和简单的错误消息,这不是非常有用的。



http://msdn.microsoft.com/en-us/library/aa702726.aspx 我发现如何启用更详细的日志记录。不幸的是,这似乎相当静态。我想从代码中进行配置(保留10个旧文件,指定应用程序启动时存储日志文件的路径...),但到目前为止,我还没有找到任何体面的例子。



甚至可以从代码中执行此操作,有人可以给出任何指针,了解如何以及需要做什么?

解决方案

我不认为这是可能的。消息记录基于System.ServiceModel.Diagnostics命名空间中的静态MessageLogger类。这个类是内部的,它是以ServiceHostBase的私有OnBeginOpen方法被初始化(从配置文件)。


I am communicating between two processes using WCF. By default this produces very obscure and simple error messages when something goes wrong which are not very helpful.

On http://msdn.microsoft.com/en-us/library/aa702726.aspx I found out how I can enable more detailed logging. Unfortunately this seems rather static. I would like to do and configure this from code (keep 10 "old" files, specify the path where to store the log files when the application starts...) but so far I have not found any decent examples.

Is it even possible to do this from code and can someone give any pointers on how and what I need to do?

解决方案

I don't think it is "possible". Message logging is based on static MessageLogger class from System.ServiceModel.Diagnostics namespace. This class is internal and it is initialized (from config file) in private OnBeginOpen method of ServiceHostBase.

这篇关于如何从代码而不是应用程序配置文件启用WCF消息日志记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆