There are other alternatives to creating another log-only service. You can create a log as an aspect and attach / detach this aspect (aka inject), when and when needed, any ServiceContract or OperationContract . Thus, you disable logging, but this avoids the overhead of calling another service for each call. After you create these aspects, compile them in a separate binary file and use them as needed in all of your future services, enabling and disabling certain logging scripts is more convenient for IMO than having a dedicated log-only service.
Take a look at the following two posts, and they provide a simplified approach to this, you need to fill the flesh as you want for your project.
Important MSDN documentation you want to look at.
Edit - Code Example
Using the code below, you add [OperationLogging] on any of your work contracts, and you can intercept calls to this operation contract in LoggingInspector.BeforeCall .
Use [ServiceLogging] for any service contract, and all operations defined in these service calls can be intercepted and logged.
Set your_app_config_key to anything other than TRUE ; these additional behaviors are not added to your service pipeline. This is very cool since none of this code is executed based on this key in config.
public class LoggingInspector : IParameterInspector { private string service; public LoggingInspector(string serviceName){ service = serviceName;} public void AfterCall(string operationName, object[] outputs, object returnValue, object correlationState){} public object BeforeCall(string operationName, object[] inputs) {
source share