Khi bạn cần debug hay handle exception trong chương trình
bạn có thể tự viết hàm ghi log nhưng log4net có thể làm giúp bạn rất tốt với 5 kiểu khác nhau:
- Debug
- Information
- Warnings
- Error
- Fatal
Dưới dây là 1 đoạn log exception:
2021-09-18 15:30:43,751 [5] ERROR MonitoringLogger - Load index error
System.DivideByZeroException: Attempted to divide by zero.
at WebApp.Controllers.HomeController.Index() in P:\****\Controllers\HomeController.cs:line 37