私は 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;
}