For the output of the error log, we use the two flag bits of Web. config:
<!--Global Wrapper exception handling page, only in Pageerror and Application_Error do clear error action can not jump -<!--set to OFF when debugging, production environment This entry must be on -<customErrorsMode= "Off"defaultredirect= "~/errorpage/404/index.html"><ErrorStatusCode= "404"redirect= "~/errorpage/404/index.html"/></customErrors>
<!-- set to True when debugging, production environment This entry must be false - < Debug= "true" targetframework= "4.0">
Where I rewrite three events: the base class of the background page overrides the "Pageerror", the base class of the foreground MVC overrides the "Controllerexception (this event is a custom name, a reference to MVC's error rewrite)," global "application_ Error ", and then follow these guidelines:
1, "Application_Error":
① for foreground error prompt policy, non-debug mode, open the default error jump page, all only the stack to the database, do not wrap the jump, use the default error jump page
② in non-debug mode, the stack is displayed only when localhost accesses the site
③ non-debug mode, no default error jump is turned on, direct output of package exception information
2, "controllerexception":
①MVC foreground error prompt policy, non-debug mode, open the default error jump page, all only record stacks to the database, do not wrap the jump, use the default error jump page
② in non-debug mode, the stack is displayed only when localhost accesses the site
③ non-debug mode, no default error jump is turned on, direct output of package exception information
3, "Pageerror":
① background error Prompt policy, non-debug mode, all record stack to database, and wrapper jump
② in non-debug mode, the stack is displayed only when localhost accesses the site
Attachment:
Error page Template: Https://github.com/easonjim/3_web_example/tree/master/htmlpage
Error log wrapper policy for ASP. NET production environment and development environment