Logging across service boundaries

Topics: Building and extending application blocks, Logging Application Block
Nov 10, 2010 at 10:35 PM


Do you guys have any pointers of using EL 5.0 in the following scenario :

I have a client WPF application that feeds off data supplied from a set of WCF services.

One of the requirements we are facing is the ability to be able to turn logging on on a request basis for client and the services satifying those requests.

(Both client and services are logging information to a central source = DB) 

In other words;

  • On a pariticular client machine, I wanted to activate logging (as at Verbose severity) and trace the operations within the client as well as the associated operation behind the service calls on the WCF box.

Have you guys tackled this type of problem before?



Nov 11, 2010 at 3:22 AM

I think you're looking for a way to modify the configuration file at runtime so as to be able turn on logging at runtime?  If yes, then check out the Fluent Configuration API of EntLib 5.0 - http://msdn.microsoft.com/en-us/library/ff664363(PandP.50).aspx


Nov 12, 2010 at 8:31 PM

Hey Ris

Thanks for the info...... I had been looking into that.

Basically the thought was ....

From the client, send data within a custom WCF header indicating to the service that it needs to start logging at a severity other than that indicated within the web.config ().

The service will see this WCF header and construct a EL logWriter using the Fluent Config API at R/T. This (I am hoping) will allow the server to log these client specific requests to our central DB.

Other clients (where no custom WCF header info has been injected ) using this service,  will log at the level fed from the service's web.config file. 

I guess my concern is can I isolate different logging strategies this way....... i.o.w. build one up at R/T using Fluent approach while other requests using the config as specified within the .config files

Cheers Alistiar  

Nov 15, 2010 at 3:09 AM

For requests which would use the configuration file, you can update the EnterpriseLibraryContainer.Current object to use the default configuration source:

IConfigurationSource defaultConfigSource = ConfigurationSourceFactory.Create();
EnterpriseLibraryContainer.Current = EnterpriseLibraryContainer.CreateDefaultContainer(defaultConfigSource);

The default is always the web/app.config file unless you specified otherwise in your config in the enterpriseLibrary.ConfigurationSource section.


Sarah Urmeneta
Global Technologies & Solutions
Avanade, Inc.