현재 내가 여기 LogException()
방법에서 예외에 대한 명확한 & 상세 정보를 얻을 수 있습니다 follows-예외 로깅
public ActionResult Login()
{
try
{
throw new Exception("test");
}
catch (Exception ex)
{
LogException(ex);
}
return View();
}
으로 예외를 기록합니다. 나는 소스에 대한 정보를 얻기하지하고 세 abose 경우 OnException 방법 -
public abstract class BaseController : Controller
{
public BaseController() {}
protected override void OnException(ExceptionContext filterContext)
{
Exception ex = filterContext.Exception;
filterContext.ExceptionHandled = true;
LogException(ex);
}
}
과부하 나는 또한 시도
public class MyCustomAttribute : FilterAttribute, IExceptionFilter
{
public void OnException(ExceptionContext filterContext)
{
Exception ex = filterContext.Exception;
LogException(ex)
}
}
public class MyCustomAttribute : HandleErrorAttribute
{
public override void OnException(ExceptionContext filterContext)
{
Exception ex = filterContext.Exception;
LogException(ex)
}
}
- 나는 동일한 방법을 시도
Created on: 27-Dec-2016, 06.34.33 PM
Type: System.Exception
Error Description: test
Source File: ...\Controllers\LoginController.cs
Method: Login
Line: 20
Column: 17
below-보기 파일, 방법, 행 및 열 -
Created on: 27-Dec-2016, 06.44.45 PM
Type: System.Exception
Error Description: test
Source File:
Method: <BeginInvokeAction>b__1e
Line: 0
Column: 0
01 23,516,
이 내 방법은 예외 중 기록하는 것입니다
public static void Create(Exception exception, String rootDirectoryPath)
{
try
{
StackTrace st = new StackTrace(exception, true);
StackFrame frame = st.GetFrame(st.FrameCount - 1);
string fileName = frame.GetFileName();
string methodName = frame.GetMethod().Name;
int line = frame.GetFileLineNumber();
int col = frame.GetFileColumnNumber();
//Other code .....
}
catch (Exception)
{
//do nothing.
}
}
내 질문이있다가 그 세 경우와 소스 파일, 방법, 행 및 열 정보를 검색 할 수 있습니까?
매번 try .. catch..
을 작성하여 예외를 처리하고 싶지 않습니다.
나는 ELMAH & Log4Net에 관해서 들었습니다. 그러나 라이브러리가 예외로부터 원하는 정보를 제공 할 수 있는지 여부는 확실하지 않습니다.
대단히 죄송합니다.
글쎄, ELMAH 이외의 방식으로하고 싶다면? –
그런 다음 소스 코드를 확인하여 코드에서 수행하고 복제하는 방법을 확인하는 것이 좋습니다. https://github.com/elmah/Elmah –