如何从代码而不是应用程序配置文件启用WCF消息日志记录 [英] How to enable WCF message logging from code instead of the application configuration file
问题描述
在 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屋!