Use ASP. NET to write webpage error information to system logs

Source: Internet
Author: User

When designing a website, it is impossible for our website to have no errors. common error messages such as "page does not exist" and "Page Operation error" always exist. The key is, after these errors occur, the administrator can easily discover them in a timely manner and minimize users' bad impression on the website. Whether it is IIS 4 or IIS 5, we can set the "custom error message" of the website, some of the default unfriendly error messages of the system can be changed to the custom page of the website administrator, which is helpful for the practicality and friendliness of the website. However, we found an inconvenient problem during use. When we checked the website logs, we found these error pages. However, however, you cannot view these error messages in system events. It is troublesome to view the error information in the log Part of the website. Is there a way to directly store the generated error information in the system log part like the security log? ASP. NET can be implemented now. Now, we will learn how to implement this function step by step.
1. Create an EventLog virtual directory
To achieve this, we create a virtual directory named "EventLog" on our website. The procedure is as follows: in Win2000, choose Start> program> Administrative Tools> Internet Information Service, find the website you have created, and click Create in the email box ", select "virtual directory" in the pop-up menu and follow the wizard settings.
2. Modify the WEB. CONFIG file
We know that in the WEB. CONFIG file, we can set the location of the error information page and whether to display the error information like the "custom error information" page of IIS. To implement the functions mentioned in this article, we need to modify the WEB. in the CONFIG file, open "mermerrors mode" and set it to "ON". Non-computer users can only get friendly (custom) error information. The specific settings are as follows:
<Configuration>
<System. web>
<CustomErrors mode = "On" defaultRedirect = "/eventlog/customerrorpage. aspx">
<Error statusCode = "404" redirect = "/eventlog/404Page. aspx"/>
<Error statusCode = "403" redirect = "/eventlog/403page. aspx"/>
</CustomErrors>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.