2013-08-08 15 views

Odpowiedz

32

Tak, można użyć ErrorSignal bez rzuca wyjątek.

ErrorSignal.FromCurrentContext().Raise(new NotSupportedException()); 

Dla asn, można utworzyć niestandardową wyjątku.

var customEx = new Exception("Hello I am testing Elmah", new NotSupportedException()); 
ErrorSignal.FromCurrentContext().Raise(customEx); 
+0

dzięki za szybką odpowiedź – user603007

11

Spróbuj

Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception("Your message")); 
1

wiem, jest to stara sprawa, ale jeśli nie chcesz utworzyć wyjątek można również użyć

var error = new Error 
{ 
    Source = eventType.ToString(), 
    Type = $"Trace-{eventType}", 
    Message = message, 
    Time = DateTime.UtcNow 
}; 

ErrorLog.GetDefault(HttpContext.Current).Log(error); 

jak pokazano na this answer .

Powiązane problemy