Global.asax.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System;
  2. using Abp.Castle.Logging.Log4Net;
  3. using Abp.Web;
  4. using Castle.Facilities.Logging;
  5. using ShwasherSys;
  6. namespace ShwasherSys
  7. {
  8. public class MvcApplication : AbpWebApplication<ShwasherWebModule>
  9. {
  10. protected override void Application_Start(object sender, EventArgs e)
  11. {
  12. AbpBootstrapper.IocManager.IocContainer.AddFacility<LoggingFacility>(
  13. f => f.UseAbpLog4Net().WithConfig(Server.MapPath("log4net.config"))
  14. );
  15. this.LogInfo("Application -- System Starting!");
  16. base.Application_Start(sender, e);
  17. this.LogInfo("Application -- System Started!");
  18. }
  19. protected override void Application_End(object sender, EventArgs e)
  20. {
  21. // 在应用程序关闭时运行的代码
  22. this.LogInfo("Application -- System End!");
  23. }
  24. protected override void Application_Error(object sender, EventArgs e)
  25. {
  26. // 在出现未处理的错误时运行的代码
  27. //获取到HttpUnhandledException异常,这个异常包含一个实际出现的异常
  28. Exception ex = Server.GetLastError();
  29. //实际发生的异常
  30. Exception innerException = ex.InnerException;
  31. if (innerException != null) ex = innerException;
  32. this.LogFatal(ex);
  33. }
  34. protected override void Session_Start(object sender, EventArgs e)
  35. {
  36. // 在新会话启动时运行的代码
  37. this.LogInfo("Session_Start");
  38. }
  39. protected override void Session_End(object sender, EventArgs e)
  40. {
  41. // 在会话结束时运行的代码。
  42. // 注意: 只有在 Web.config 文件中的 sessionstate 模式设置为 InProc 时,才会引发 Session_End 事件。
  43. // 如果会话模式设置为 StateServer
  44. // 或 SQLServer,则不会引发该事件。
  45. this.LogInfo("Session_End");
  46. }
  47. }
  48. }