Wednesday, June 21, 2017

How to change the logging configuration of a WCF service at runtime with WMI

We have always been recommended to set the trace level of our WCF services to "warning" in the production environments so as not to impact on the performance and not to generate a large amount of data. However, when we detect an issue with our services we should be able to modify the trace level to "verbose" to facilitate the troubleshooting process.

If we modify the trace level in the configuration file of our services, we will be forced to restart them so that the change to take effect, both when modifying to Verbose and when modifying to Warning. However, in some productive environments it's not possible restart the services (processes).

For this reason, the best option to modify the trace level in runtime is WMI. We can activate the WMI provider of our WCF services including the following entry in the "system.serviceModel" section of the configuration file:

<diagnostics wmiProviderEnabled="true" />

Once the provider is activated, we can modify the trace level of our WCF services in runtime with PowerShell:

No comments:

Post a Comment