1

asp.mvc3 アプリケーションですべての例外を処理するための 1 つのグローバル ポイントが必要です。新しいアプリケーションを作成し、nuget を使用して elmah を追加し、ElmahCustomLogger クラスを実装しました。また、このカスタム ロガーを web.config elmah セクションに登録しました。

何らかの理由で ElmahCustomLogger::Log メソッドが呼び出されることはありません (私はそこにブレーキポイントを置いています)

public class ElmahCustomLogger : ErrorLog 
{
    public override string Log(Error error)
    {
        throw new NotImplementedException();
    }

    public override ErrorLogEntry GetError(string id)
    {
        throw new NotImplementedException();
    }

    public override int GetErrors(int pageIndex, int pageSize, IList errorEntryList)
    {
        throw new NotImplementedException();
    }
}
4

2 に答える 2

4

それを機能させるには、特定のコンストラクターを宣言するだけでよいようです。

public class ElmahCustomLogger : Elmah.ErrorLog
{
    public ElmahCustomLogger(IDictionary config) {}
    ...
}
于 2013-03-06T19:18:31.177 に答える