Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 735
Jensen Avatar asked Aug 30 '10 11:08

Jensen


1 Answers

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.

like image 199
Ladislav Mrnka Avatar answered Nov 15 '22 06:11

Ladislav Mrnka