Elmah messaggio metti in errore registrato attraverso la chiamata a Raise (e)
-
26-09-2019 - |
Domanda
Sono un po 'confuso come aggiungere un messaggio a un errore registrato programatically con ELMAH.
es:
public ActionResult DoSomething(int id)
{
try { ... }
catch (Exception e)
{
// I want to include the 'id' param value here, and maybe some
// other stuff, but how?
ErrorSignal.FromCurrentContext().Raise(e);
}
}
Sembra tutto Elmah può fare è accedere eccezione grezzo, come posso anche registrare il mio informazioni di debug?
Soluzione
Si può lanciare una nuova impostazione della originale come l'eccezione interna di eccezione e ELMAH registrerà i messaggi per entrambi:
catch(Exception e)
{
Exception ex = new Exception("ID = 1", e);
ErrorSignal.FromCurrentContext().Raise(ex);
}
mostrerà
System.Exception: ID = 1 ---> System.NullReferenceException: Object reference not set to an instance of an object.
Altri suggerimenti
ho scoperto che posso anche fare qualcosa di simile:
Elmah.ErrorSignal.FromCurrentContext().Raise(new NotImplementedException("class FbCallback.Page_Load() Request.Url= " + Request.Url));
Per collegarvi i miei messaggi. Poi, nel quando navigo a
http://localhost:5050/elmah.axd
vedo i miei messaggi come tipo NotImplementedException. Non molto bella, ma funziona.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow