WCF Service and logging

Topics: Logging Application Block
Jan 20, 2009 at 5:14 PM
I had written my own tracelistener which is essentially a rolling file trace listener. Due to requirement changes I'm looking at the LAB, but I want to make sure what I need is possible and any hints on what to look for.

We have WCF Service which loads the environment (production, test, development, etc.)  from the config file and writes a rolling trace file. However, we are hooking up additional applications to the WCF Service and the request was made that the WCF Service logs to seperate log files based on the application if possible, the environment that made the service request.

For example,

App1 in development calls the WCF Service and the service logs everything to App1_dev.log.
App2 in production calls the WCF Service and the service logs everything to App2_prod.log.

Before I start poring over source code, I wanted to know if anyone can confirm that this is possible using LAB?

Thanks,

Donovan

Jan 21, 2009 at 4:17 AM
You could use the Environmental Overrides feature of EntLib.  See this thread for some links to tutorial :
http://www.codeplex.com/entlib/Thread/View.aspx?ThreadId=10232


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com
Jan 23, 2009 at 3:40 PM
I have a need for this too. In my case, I need to log to separate databases for each client.
Sarah, perhaps I'm missing something in the Environmental Overrides feature, but I'm not sure how it would address this particular problem.
The situation I have (and I believe that cartango has as well) is that there are multiple web clients, in the same environment, hitting the WCF service. Logged messages for tht two clients should be routed to separate log files (or in my case, databases).

Suggestions?

Mark


Jan 23, 2009 at 3:44 PM
Mark, although I'm not a web scenario, you are correct in your assesment of what I am looking for.

Donovan
Jan 23, 2009 at 4:00 PM
Hi, Donovan,

Is the Environmental Override going to work for you in your scenario?
I re-read your initial post (after some more coffee) and I realized I was a bit off on my comparison of our two situations. I missed the "App2 in production" part of your example. Sorry about that.
Your example was:
App1 in development calls the WCF Service and the service logs everything to App1_dev.log.
App2 in production calls the WCF Service and the service logs everything to App2_prod.log.

My example is similar, but looks like this:
WCF web Client 1 in Production calls the WCF Service (in production) and the service logs everything to Client1 database.
WCF web Client 2 in Production calls the WCF Service (in production) and the service logs everything to Client2 database.

I hope I'm wrong, but at this point I think I'm looking at a bit of custom LAB code in addition to my custom trace listener. It looks to me that I'd need to pass some sort of client identifier to the Logger and have custom code in there to route to the correct target database based on that identifier.

Mark
Jan 23, 2009 at 4:11 PM
Actually, I didn't extropolate the full mess I was in.

App1 in development calls the WCF Service and the service logs everything to App1_dev.log.
App1 in production cals the WCF Service and the service logs everything to App1_prod.log.
App2 in development calls the WCF Service and the service logs everything to App2_dev.log.
App2 in production calls the WCF Service and the service logs everything to App2_prod.log.

However, since that time, we decided to not have the same service, "service" all environments, just multiple applications. In addition, I should state, that while I said production, production is actually on it's own box. The same service was actually for dev, testing, training, staging.

As far as if the Environment variables will work for me, It would solve my problem with the different environments, but I do not think it will help with different applications.