开发者

elmah throws a signal, difference with real exception when I look at the log

开发者 https://www.devze.com 2023-02-19 13:01 出处:网络
When I throw a signal to Elmah, it catches it, then I can开发者_如何学JAVA find the exception via Elmah.axd page, my questions is, on the elmah.axd page, can I tell if the exception is from a signal o

When I throw a signal to Elmah, it catches it, then I can开发者_如何学JAVA find the exception via Elmah.axd page, my questions is, on the elmah.axd page, can I tell if the exception is from a signal or a really exception there, from the log?


The best way to sort these is to create a custom exception. We use one called "LogMessageException". Whenever we are just signaling some logging information we use this.

That way we can filter out the logging noise from the real exceptions.

update with sample class and call:

public class LogMessageException : Exception {
    private LogMessageException() : base() {
    } // privatizing original constructor

    public LogMessageException( String message ) : base(message) {
    } // 

} // class::LogMessageException 

Sample Call

Elmah.ErrorSignal.FromCurrentContext().Raise(new LogMessageException("Say something here"));
0

精彩评论

暂无评论...
验证码 换一张
取 消