Search code examples
asp.net-mvcelmah

Elmah - don't log full stack trace


I would like to control the Elmah log - specifically I would like to not record the full stack trace. Is it possible to control what Emlah actually logs? I know you can filter the type of errors, but what about the contents of the message?


Solution

  • ELMAH doesn't offer a hook to allow you to modify the message before storing it. The only ways to do this is to modify the ELMAH source (not recommended) or to create a new error log, inheriting from the error logger you are currently using:

    public class MySqlErrorLog : SqlErrorLog
    {
        public MySqlErrorLog(IDictionary config) : base(config)
        {
            ...
        }
    
        public override string Log(Error error)
        {
            error.Detail = string.Empty;
    
            return base.Log(error);
        }
    }