Three minutes integrated Elmah XML format log to MVC site

Source: Internet
Author: User

1. Installing Elmah through NuGet

ELMAH on XML log automatically adds configuration content to the Web. config file, does not allow remote access by default, log access path is Elmah.axd, 500 error is not logged

2. Modify the configuration file

500 increase in exception logging, allowing remote access

 <Elmah>    <!--See Http://code.google.com/p/elmah/wiki/SecuringErrorLogPages for more information in remote access an    D Securing ELMAH.  -    <Securityallowremoteaccess= "true" />    <errorlogtype= "Elmah.xmlfileerrorlog, Elmah"LogPath= "~/app_data/elmah.errors" />    <Errorfilter>      <Test>        <Equalbinding= "HttpStatusCode"value= "404"type= "Int32" />        <Equalbinding= "HttpStatusCode"value= "$"type= "Int32" />      </Test>    </Errorfilter>  </Elmah>

modifying access paths

< LocationPath= "log.axd"inheritinchildapplications= "false">    <system.web>      <httphandlers>        <Addverb= "Post,get,head"Path= "log.axd"type= "Elmah.errorlogpagefactory, Elmah" />      </httphandlers>      <!--See Http://code.google.com/p/elmah/wiki/SecuringErrorLogPages for more information on using ASP.      Uthorization securing ELMAH.      <authorization> <allow roles= "admin"/> <deny users= "*"/> </authorization>  -    </system.web>    <system.webserver>      <handlers>        <Addname= "ELMAH"verb= "Post,get,head"Path="Log.axd"type= "Elmah.errorlogpagefactory, Elmah"Precondition= "Integratedmode" />      </handlers>    </system.webserver>  </ Location>

There are many Elmah extensions on NuGet that can be stored in other formats.

Three minutes integrated Elmah XML format log to MVC site

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.