Error logging tool elmah.

Source: Internet
Author: User

Recently, the company's servers often encounter errors, leading to the inability to access the website. Therefore, we think of the error reminder emails that the company used before. We often receive system reports of the Yellow Pages, this helps us fix possible bugs and ensure system stability and a good user experience.

At present, an entrepreneurial company needs to do everything on its own. If this is not the case, it will take a long time to deploy this elmah tool on the current system.

MACHINE: Windows 7 operating system, Home edition, and potholes cannot install IIS, and can only be debugged locally.

Project: Asp.net mvc4

Add a reference to elmah. dll in your current project. You can also use nugit to automatically deploy elmah. For details, refer to the blog:

The local webconfig should be configured as follows:

1. Add the followingCodeGo to the <configsections> Configuration node:

<Sectiongroup name = "  Elmah  " > <Section name = "  Security  " Requirepermission = " False  " Type = "  Elmah. securitysectionhandler, elmah  " /> <Section name = "  Errorlog  " Requirepermission = "  False  " Type = "  Elmah. errorlogsectionhandler, elmah  " /> <Section name ="  Errormail  " Requirepermission = "  False  " Type = "  Elmah. errormailsectionhandler, elmah  " /> <Section name = "  Errorfilter  " Requirepermission = "  False  " Type ="  Elmah. errorfiltersectionhandler, elmah  " /> </Sectiongroup>

2. Add the following code to the root node:

<Elmah> <! -- Whether remote access is allowed. 0 indicates no, 1 indicates yes --> <Security allowremoteaccess = "  0  " /> <! -- The error message is recorded in the file --> <errorlog type = "  Elmah. xmlfileerrorlog, elmah  " Logpath = "  ~ /Logs  " /> The directory where the XML file is stored, for example, D: \ logs. Pay attention to the write permission for the corresponding directory.
<! -- The error message is sent by email. Multiple emails are separated by commas. --> <Errormail From = " Sender " To = " Inbox separated by commas " Subject = " Email Subject " Async = " True " Smtpport = " 25 " Smtpserver = "Email server " Username = " Sender Username " Password = " Password " /> </Elmah>

3. Add the following code to the system. Web configuration node:

<Httphandlers> <add verb = "  Post, get, head " Path = "  Elmah. axd  " Type = "  Elmah. errorlogpagefactory, elmah  " /> </Httphandlers>  "  Errorlog  " Type = "  Elmah. errorlogmodule, elmah  " /> <Add name ="  Errormail  " Type = "  Elmah. errormailmodule, elmah  " /> </Httpmodules>

Run your ownProgramAnd then access the page, for example, http: // localhost: 1149/elmah. axd. If noerror is displayed, the configuration is successful.

Then, you can find some trouble in your application to make it Yellow Pages. Refresh the page and a corresponding error record will appear. Colleague, if the mailbox is set successfully, the mailbox will receive an email.

This configuration cannot be configured on server 404. If you visit the site \ elmah. axd, a error will be prompted. You can modify the configuration in step 3 as follows:

In step 3, add the following code to the system. webservers node: Do not repeatedly pull handlers and modules nodes. (Both handlers and modules nodes exist by default.

<Handlers> <Add name = " Elmah  " Verb = "  Post, get, head  " Path = "  Elmah. axd  " Type = "  Elmah. errorlogpagefactory, elmah  " Precondition = "  Integratedmode  " /> </Handlers> <modules runallmanagedmodulesforallrequests ="  True  " > <Add name = "  Errorlog  " Type = "  Elmah. errorlogmodule, elmah  " /> <Add name = "  Errormail  " Type = "  Elmah. errormailmodule, elmah  " /> </Modules>

The general process is like this. I did not go into the details. I do not know why the 404 error is not reminded. I only send an email notification to the yellow page error.

If you have any knowledge, please remind me.

 

 

 

 
 

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.