为程序添加log日志
2018-04-10 18:02 辛晓心 阅读(1003) 评论(0) 收藏 举报<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" /> <section name="errorTweet" requirePermission="false" type="Elmah.ErrorTweetSectionHandler, Elmah" /> </sectionGroup> <httpModules> <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" /> <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" /> <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" /> <add name="ErrorTweet" type="Elmah.ErrorTweetModule, Elmah" /> <add name="Glimpse" type="Glimpse.AspNet.HttpModule, Glimpse.AspNet" /> </httpModules> <modules runAllManagedModulesForAllRequests="true"> <remove name="UrlRoutingModule-4.0" /> <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" /> <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" /> <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" /> <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" /> <add name="ErrorTweet" type="Elmah.ErrorTweetModule, Elmah" preCondition="managedHandler" /> <add name="Glimpse" type="Glimpse.AspNet.HttpModule, Glimpse.AspNet" preCondition="integratedMode" /> </modules> <elmah> <security allowRemoteAccess="false" /> <!--三种存储方式:内存、xml、数据库。存储到xml里面格式如下行--> <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/Static/Log/" /> <!--<errorLog type="Elmah.OracleErrorLog, Elmah" connectionStringName="DefaultConnection" />--> <errorFilter> <!--<test> <and> --> <!--排除404 error--> <!-- <equal binding="HttpStatusCode" value="404" type="Int32" /> </and> </test>--> </errorFilter> <errorTweet maxStatusLength="100" url="https://slack.com/api/chat.postMessage" formFormat="token=xoxp-9404739216-9405040759-12378018532-7808a2aedc&channel=#nawf&text={0}&username=elmah" /> </elmah> <location path="log.axd" inheritInChildApplications="false"> <system.web> <httpHandlers> <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" /> </httpHandlers> <!-- See http://code.google.com/p/elmah/wiki/SecuringErrorLogPages for more information on using ASP.NET authorization securing ELMAH. <authorization> <allow roles="admin" /> <deny users="*" /> </authorization> --> </system.web> <system.webServer> <handlers> <add name="ELMAH" verb="POST,GET,HEAD" path="log.axd" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" /> </handlers> </system.webServer>
引用elmah插件
nuget包里找到elmah安装 ,然后webconfig里配置

浙公网安备 33010602011771号