In C #. net website projects often need to record error logs. The previous practice is to record error exceptions to the data table of an error log, however, after a project needs to be connected to the VPN, the access speed to the database is really unsatisfactory for every view of the Error Log, so I found a third-party elmah logging tool for error backup, elmah supports many formats, including saving XML or log notepad files and saving them to the database. I only saved the XML format on the server hard disk here, which is convenient for reference.
1. Web. config configuration item
<? XML version = "1.0"?> <! -- For more information on how to configure your ASP. NET application, please visit http://go.microsoft.com/fwlink? Linkid = 169433 --> <configuration> <configsections> <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 "requ Irepermission = "false" type = "elmah. errorfiltersectionhandler, elmah"/> </sectiongroup> </configsections> <! -- The log file path is configured here --> <elmah> <! -- Allowremoteaccess attribute indicates whether remote access is allowed. if this value is set to 0, then the error log web page can only be viewed locally. if this attribute is set to 1 then the error log web page is enabled for both remote and local visitors. --> <Security allowremoteaccess = "1"/> <errorlog type = "elmah. xmlfileerrorlog, elmah "logpath =" D: \ Scott \ projects \ AZ sales \ 06. construction \ sourcecode \ azsales \ log "/> </elmah> <system. web>
After the configuration is complete, no other code is added to the website code.
To view elmah logs, add elmah and axd to the web site.
For example, http: // localhost: 3721/elmah. axd