locked
Message Logging in WCF. RRS feed

  • Question

  • Hi

    I want to know, if there is any way in WCF, that specific users can enable message logging for service at run time via configuration file.

    Thanks

    Saturday, January 11, 2014 10:47 PM

Answers

  • Hello,

    Yes... but you would not want to do this against the web.config as it would cause the service to restart.  Also my guess is you want to be able to log activity regarding the specific user separately from other users activity.  WCF logging via config is mainly used monitor/diagnose the service as a whole and would not lend itself easily to targeting specific users.

    My guess is you need something a bit more custom.  I am just guessing about the requirements but if you want to be able to log each users activity independently then I would identify something in the contract (probably a parameter in the header) that identifies the service call's user.  I would then create a custom messageinspector that would identify if the message should be logged.


    Jeff

    Sunday, January 12, 2014 8:28 PM
  • Ok, I understand more.  I am sure the Microsoft guys can explain this better but in my mind enabling the wmi provider

    <diagnostics wmiProviderEnabled="true" />

    wires up WCF to promote the events so that applications can listen to them via the WMI APIs.  This would then allow you to enable/disable the applications at runtime independently of the service.  You can not do this with XML Trace Listener or Message logging in the configuration file as this would affect the service (bounce it).  debug compilation does not make sense.

    You find other ways of solving this by creating a custom trace listener or customer wcf behaviour but these were not listed as options.


    Jeff

    Wednesday, January 15, 2014 12:23 AM

All replies

  • Hello,

    Yes... but you would not want to do this against the web.config as it would cause the service to restart.  Also my guess is you want to be able to log activity regarding the specific user separately from other users activity.  WCF logging via config is mainly used monitor/diagnose the service as a whole and would not lend itself easily to targeting specific users.

    My guess is you need something a bit more custom.  I am just guessing about the requirements but if you want to be able to log each users activity independently then I would identify something in the contract (probably a parameter in the header) that identifies the service call's user.  I would then create a custom messageinspector that would identify if the message should be logged.


    Jeff

    Sunday, January 12, 2014 8:28 PM
  • Thanks for your reply. I do understand what you are saying.But This was a question asked in 70-513 exam.

    Question was something like this.

    You are creating WCF Service and you need to ensure that specific users can enable message logging for the service at runtime. How would you do this via configuration file for the service.

    Options were somthing like below.

    1. Enable debug compilation 2. enbale XML Trace Listener 3. Enable WMI provider.4. Enable Message logging.

    As per my understanding, the ans should be option 3(Enable WMI provider). 

    Please help.

    Monday, January 13, 2014 4:49 AM
  • Ok, I understand more.  I am sure the Microsoft guys can explain this better but in my mind enabling the wmi provider

    <diagnostics wmiProviderEnabled="true" />

    wires up WCF to promote the events so that applications can listen to them via the WMI APIs.  This would then allow you to enable/disable the applications at runtime independently of the service.  You can not do this with XML Trace Listener or Message logging in the configuration file as this would affect the service (bounce it).  debug compilation does not make sense.

    You find other ways of solving this by creating a custom trace listener or customer wcf behaviour but these were not listed as options.


    Jeff

    Wednesday, January 15, 2014 12:23 AM
  • thanks Jeff
    Wednesday, January 15, 2014 3:41 AM