Elmah配置

<?xml version="1.0" encoding="utf-8"?>
<configuration>

    <configSections>
        <sectionGroup name="elmah">
            <!-- NOTE! If you are using ASP.NET 1.x then remove the
                 requirePermission="false" attribute from the section
                 elements below as those are only needed for
                 partially trusted applications in ASP.NET 2.0 -->
            <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"/>
            <section name="errorTweet" requirePermission="false" type="Elmah.ErrorTweetSectionHandler, Elmah"/>
        </sectionGroup>
    </configSections>

    <elmah>
    
        <security allowRemoteAccess="0" />

        <!--
            Use to log errors to Microsoft SQL Server 2000 or 2005
            using ASP.NET 2.0. Set value of connectionStringName attribute
            to the name of the connection string settings to use from
            the <connectionStrings> section.
        
        <errorLog type="Elmah.SqlErrorLog, Elmah" 
            connectionStringName="..." />
        -->

        <!--
            Use to log errors to Microsoft SQL Server 2000 or 2005
            using ASP.NET 1.x and adjust the value of connectionString 
            attribute to your settings.

        <errorLog type="Elmah.SqlErrorLog, Elmah" 
            connectionString="Data Source=.;Initial Catalog=ELMAH;Trusted_Connection=True" />
        -->
        
        <!--
            Use to log errors to SQLite using ASP.NET 2.0. 
            Set value of connectionStringName attribute to 
            the name of the connection string settings to 
            use from the <connectionStrings> section.
            
        <errorLog type="Elmah.SQLiteErrorLog, Elmah" connectionStringName="..." />
        
            The format of the connection string should be as follows:
            
        <connectionStrings>
          <add name="..." connectionString="data source=[path to the database file]" />
        </connectionStrings>
            
            Replace the content of the brackets with a file name, for example:
            
        data source=C:\Elmah.db
            
            If the database file doesn't exist it is created automatically.
            To specify a path relative to and below the application root, 
            start with the root operator (~) followed by a forward slash (/), 
            as it is common in ASP.NET applications. For example:
            
        data source=~/App_Data/Error.db
        -->

        <!--
            Use to log errors into separate XML files that are stored on 
            disk at the path specified in the logPath attribute.

        <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="..." />
        -->

        <!--
            Use to log errors to Oracle
            using ASP.NET 2.0. Set value of connectionStringName attribute
            to the name of the connection string settings to use from
            the <connectionStrings> section.
        
            The schemaOwner parameter is *optional*. Use this if the owner of the
            ELMAH package (pkg_elmah$error) is not the same user that you are 
            using to connect to the database.
            
        <errorLog type="Elmah.OracleErrorLog, Elmah" 
            schemaOwner="xxx" />
            connectionStringName="..." />
        -->

        <!--
            Use to log errors to Oracle
            using ASP.NET 1.1 and adjust the value of connectionString 
            attribute to your settings.

            The schemaOwner parameter is *optional*. Use this if the owner of the
            ELMAH package (pkg_elmah$error) is not the same user that you are 
            using to connect to the database.

        <errorLog type="Elmah.OracleErrorLog, Elmah" 
            schemaOwner="xxx" />
            connectionString="Data Source=xxxx;User ID=username;Password=password" />
        -->

        <!--
            Use to log errors to Microsoft Access
            using ASP.NET 1.x and adjust the value of connectionString 
            attribute to your settings.
            Use Elmah.mdb as your database.

        <errorLog type="Elmah.AccessErrorLog, Elmah" 
            connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|Elmah.mdb" />
        -->

        <!--
            Use to log errors to Microsoft Access
            using ASP.NET 2.0. Set value of connectionStringName attribute
            to the name of the connection string settings to use from
            the <connectionStrings> section.
            Use Elmah.mdb as your database.
        
        <errorLog type="Elmah.AccessErrorLog, Elmah" 
            connectionStringName="..." />
        -->

        <!--
            Use to log errors to VistaDB Express
            using ASP.NET 2.0. Set value of connectionStringName attribute
            to the name of the connection string settings to use from
            the <connectionStrings> section.
        
        <errorLog type="Elmah.VistaDBErrorLog, Elmah" 
            connectionStringName="..." />

            The format of the connection string should be as follows:
            
        <connectionStrings>
          <add name="..." connectionString="Data Source='[path to the database file]';Open Mode=NonExclusiveReadWrite;Pooling=True" providerName="VistaDB.Provider" />
        </connectionStrings>
            
            Replace the content of the brackets with a file name, for example:
            
        Data Source='C:\Elmah.vdb3'
            
            If the database file doesn't exist it is created automatically.
            To specify a path relative to and below the application root, 
            start with the root operator (~) followed by a forward slash (/), 
            as it is common in ASP.NET applications. For example:
            
        Data Source='~/App_Data/Error.vdb3'
        
            You can also specify the App_Data directory using the
            |DataDirectory| macro. For example:
        
        Data Source='|DataDirectory|\Elmah.vdb3'
        
            Note the use of the Open Mode and Pooling parameters
        -->


        <!--
            Use to send error reports by e-mail and adjust the attributes
            according to settings desired. Note that only the from and
            to attributes are required. The rest are optional and may
            be removed. If the SMTP server does not require authentication,
            you MUST remove the userName and password attributes or
            set them to empty values (resulting in zero-length strings).
            If you are using ELMAH compiled for .NET Framework 1.x, then
            the to attribute may contain multiple recipient addresses,
            each of which must be delimited by a semi-colon(;). If you are 
            using ELMAH compiled for .NET Framework 2.0 or later, then the
            to attribute may contain multiple recipient addresses,
            each of which must be delimited by a comma (,).

        <errorMail 
            from="elmah@example.com" 
            to="admin@example.com" 
            subject="..."
            priority="Low|Normal|High"
            async="true|false"
            smtpPort="25"
            smtpServer="smtp.example.com" 
            useSsl="true|false"
            userName="johndoe"
            password="secret" 
            noYsod="true|false" />
        -->

        <!--
            Use to send short error messages to a twitter account.
        <errorTweet 
            userName="johndoe" 
            password="secret" />
        -->

        <!--
            Use to prevent errors from being mailed or logged based on
            assertions. An assertion evaluates the current context, resulting
            in a Boolean outcome. An error is filtered if the assertion results
            in true. For a more detailed explanation, see:
            
            http://code.google.com/p/elmah/wiki/ErrorFiltering
            
            The example below will filter errors when any of the
            following conditions occur:
            
            - The status code is set to 404 
            - The root/base cause is System.IO.FileNotFoundException
            - The root/base cause is System.Web.HttpRequestValidationException
            - The user agent making the request identifies itself as "crawler"
            - The request is from the local machine
            
            The assertion below is expressed as a JScript expression and is the
            most generic and simplest of the assertions to use if you are
            familiar with the JavaScript language. It can work in Medium and
            Full trust environments.

        <errorFilter>
            <test>
                <jscript>
                    <expression>
                    <![CDATA[
                    // @assembly mscorlib
                    // @assembly System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
                    // @import System.IO
                    // @import System.Web

                    HttpStatusCode == 404
                    || BaseException instanceof FileNotFoundException 
                    || BaseException instanceof HttpRequestValidationException
                    /* Using RegExp below (see http://msdn.microsoft.com/en-us/library/h6e2eb7w.aspx) */
                    || Context.Request.UserAgent.match(/crawler/i)                      
                    || Context.Request.ServerVariables['REMOTE_ADDR'] == '127.0.0.1' // IPv4 only
                    ]]>
                    </expression>
                </jscript>
            </test>
        </errorFilter>
        -->

    </elmah>

    <system.web>

        <httpModules>
            
            <!-- 
                Uncomment the entry below if all of the following are true: 
                1) you are using wildcard mapping in IIS 5.x
                2) you are not using .Net 1.0
                3) you are experiencing http 404 errors when trying to view
                   elmah.axd or elmah.axd/detail?id=* etc
            -->
            <!--<add name="FixIIS5xWildcardMapping" type="Elmah.FixIIS5xWildcardMappingModule, Elmah"/>-->

            <!-- 
                Uncomment the entry below if you are using MS Ajax v1.0.x.x
                and want to capture errors during Partial Postbacks
                NB This is not required for the version of Ajax shipped with .Net Framework v3.5!
            -->
            <!--<add name="MsAjaxDeltaErrorLog" type="Elmah.MsAjaxDeltaErrorLogModule, Elmah"/>-->

            <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
        
            <!-- 
                Uncomment the entries below if error mail reporting 
                and filtering is desired.
            -->
            
            <!--<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />-->
            <!--<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah"/>-->
            <!--<add name="ErrorTweet" type="Elmah.ErrorTweetModule, Elmah"/>-->

        </httpModules>
        
        <httpHandlers>

            <!-- 
                This entry provides the UI for the error log at
                elmah.axd below the application path. For example,
                if your domain is www.example.com and your application
                is at the root, then you can view the error log by
                visiting the following URL:
                
                http://www.example.com/elmah.axd
                
                IMPORTANT! To secure this location, consult the
                following notes:
                
                http://code.google.com/p/elmah/wiki/SecuringErrorLogPages
            -->
            
            <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
        
        </httpHandlers>
       
    </system.web>

    <!-- 
        The <system.webServer> section is required for running ELMAH under Internet
        Information Services 7.0. It is not necessary for previous version of IIS.
        
        In general, it would be best to include it for all .NET Framework 2.0 and above
        configurations in order to have a more portable solution between various
        versions of IIS.

        IIS 5.x, IIS 6 require the modules and handlers to be declared in <system.web>
        whereas IIS 7 needs them declared here and complains if they are in fact
        declared in <system.web>. Fortunately, the
        <validation validateIntegratedModeConfiguration="false" /> entry tells IIS 7 
        not to worry about the modules and handlers declared in <system.web>.
        
        If you only ever want to use IIS 7, then do the following:
        
        1. Remove handlers and modules from <system.web>
        2. Remove the <validation validateIntegratedModeConfiguration="false" /> element
    -->
    <!--

    <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
        <modules>
            <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
            <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" />
            <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
            <add name="ErrorTweet" type="Elmah.ErrorTweetModule, Elmah" preCondition="managedHandler" />
        </modules>
        <handlers>
            <add name="Elmah" path="elmah.axd" verb="POST,GET,HEAD" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />
        </handlers>
    </system.webServer>

    -->

    <!-- 
        The following entry denies unauthenticated users access to 
        the path from where ELMAH's handlers are accessible. If you 
        have role-based security implemented, you SHOULD consider 
        instead allowing access by a particular role (for example, 
        operators and administrators).
        
        IMPORTANT: If you change the path of the handler above
        then you MUST also change the path in the location tag below
        to be the same.

        For more information, see:
        http://code.google.com/p/elmah/wiki/SecuringErrorLogPages
    -->

    <location path="elmah.axd">
        <system.web>
            <authorization>
                <deny users="?"/>
            </authorization>
        </system.web>
    </location>

</configuration>

http://stackoverflow.com/questions/766610/how-to-get-elmah-to-work-with-asp-net-mvc-handleerror-attribute/779961#779961

知识共享许可协议
《Elmah配置》常伟华 创作。
采用 知识共享 署名-相同方式共享 3.0 中国大陆 许可协议进行许可。
相邻依据:发表时间
  • 多说评论
  • 签名
  • 新浪微博
  • 默认评论
  • Tab Header 5

0 条评论 / 点击此处发表评论

Tab Content 5

开发技术


开发平台和工具

sitemap     167.29ms