How to enable WCF message logging from code instead of the application configuration file
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.
精彩评论