0

I have a WCF service and I have read that it might be good to use Unity Interception to do logging. I want to log errors and also every request and response that comes into the WCF app into the database. So I plan to create a logging class that I can call from my LoggingInterceptionBehavior class. Is it best to make my new logging class a regular instance object and just new it up in the code below, or should I make it a singleton? Here is an example of my code setup:

 class LoggingInterceptionBehavior : IInterceptionBehavior
{
    public IMethodReturn Invoke(IMethodInvocation input,
      GetNextInterceptionBehaviorDelegate getNext)
    {
        // Create a guid here to uniquely identify this call
        // Save the request in some variable for logging

        var result = getNext()(input, getNext);

        //Call logging class here to log the request/response/error

        return result;
    }
tjp69
  • 1,068
  • 9
  • 13
  • Whatever you do, do not make it a singleton class. There is no reason to do so. – nvoigt Feb 06 '15 at 21:17
  • There's not enough information here to answer the question. What's the "new logger"? Are you using log4net? Are you creating a logger from scratch? (If its from scratch you need to answer the question your self). – ErnieL Feb 08 '15 at 16:57

0 Answers0