0

我有一个 WCF 服务,并且我读到使用 Unity Interception 进行日志记录可能会很好。我想将错误以及进入 WCF 应用程序的每个请求和响应记录到数据库中。所以我计划创建一个日志类,我可以从我的 LoggingInterceptionBehavior 类中调用它。最好将我的新日志记录类设为常规实例对象,然后在下面的代码中将其新建,还是应该将其设为单例?这是我的代码设置示例:

 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;
    }
4

0 回答 0