0
我想使用異常過濾器向文件添加異常。 這是我的ILog
界面。使用異常過濾器記錄異常
public interface ILog
{
void Log(Importance importance, Func<string> message);
void Log(Importance importance, Func<string> message, Exception exception);
}
如何在下面的OnExceptipn方法中記錄異常?
public class LoggingExceptionFilter : ExceptionFilterAttribute
{
private readonly ILog _log;
public LoggingExceptionFilter(ILogFactory logFactory)
{
_log = logFactory.Create("LoggingExceptionFilter");
}
public override void OnException(ExceptionContext context)
{
// what to do here?
}
}