/// <summary> /// Actually sends the message to the underlying log system. /// </summary> /// <param name="logLevel">the level of this log event.</param> /// <param name="message">the message to log</param> /// <param name="exception">the exception to log (may be null)</param> protected override void WriteInternal(LogLevel logLevel, object message, Exception exception) { if (logLevel >= minLevel) { Error error; if (exception == null) { error = new global::Elmah.Error(); } else { error = new global::Elmah.Error(exception); } error.Message = message == null ? null : message.ToString(); error.Type = logLevel.ToString(); error.Time = DateTime.Now; errorLog.Log(error); } }
public static string AsJson(this Exception source, HttpContext context) { var error = new global::Elmah.Error(source, context); return global::Elmah.ErrorJson.EncodeString(error); }