質問

私は産卵のスレッドにApplication_Startのようなログイン例外をスローしました。ありません Context/HttpContext/HttpContext.Current, うかを取得しますログイン?

現時点でません例外は私のスレッドが書き込んで ErrorSignal.FromCurrentContext().Raise(ex); エラつの文脈ではnullになります。

かきダミー HttpContextがどうにかならないと思います。

編集- てみました ErrorSignal.Get(new HttpApplication()).Raise(ex); ではなさそうで送迎えます。

役に立ちましたか?

解決

あなたはあなたのアプリケーション名を設定していることを確認してくださいweb.configファイル

<errorLog type="Elmah.SqlErrorLog, Elmah" 
          connectionStringName="nibWeb" 
          applicationName="Nib.Services" />

し、

ErrorLog.GetDefault(null).Log(new Error(error));

を動作します

他のヒント

私は、メモリ内のログだったので

私はブレンダン・キャリーの答えのように<errorLog>を使用していませんでした。それにもかかわらず、彼のコマンドは、アプリケーションに名前を付けることなく、私の場合には素晴らしい仕事ます:

Elmah.ErrorLog.GetDefault(null).Log(new Elmah.Error(new Exception("The application has done something.")));

私は理由System.Web.Abstractions 3.5.0.0を必要とする程度の誤差で、.NET 4.0でELMAHを再コンパイルする必要がありました。誰がそれを望んでいるならば、私のcompiled-for-.NET 4.0フォークはここにある(また、強い命名):

http://code.google.com/r/scottstafford-elmah/

私が保存されたインスタンスとthis.Context.ApplicationInstanceを呼び出すことができるように、私のアプリケーションのために、私はApplication_StartElmah.ErrorSignal.Getを救いました。 ErrorSignalで、私はその後、Raiseことができます。これは、すべてのメールフィルターを通過します。

以下のコードです。 I

にFluentSchedulerを使用
public class Global : HttpApplication {
    void Application_Start(object sender, EventArgs e) {

        var application = Context.ApplicationInstance;
        FluentScheduler.TaskManager.UnobservedTaskException +=
            (FluentScheduler.Model.TaskExceptionInformation i, UnhandledExceptionEventArgs a) =>
                Elmah.ErrorSignal.Get(application).Raise(i.Task.Exception);

    }
}
scroll top