异常处理

        今天对异常处理研究了一下:在此mark一下:)

        (一):在template中的BasePage中:

                try

                        inputcheck();

                catch

                        customException();

                        WriteLog();

                finally

                        画面迁移(共同Error.aspx;子画面的迁移);

        PS:inputcheck要是overwrite的。

 

        (二):对于.Net框架的,可以把共同的异常处理写在Global中的Application_Error中:

                Exception ex = Server.GetLastError().GetBaseException();

                写Log

                迁移到错误画面。

                

        (三):对于Log的处理:根据不同的情况,出力不同的log

                1,Trace:有关画面迁移、花费的时间等。

                2,Debug:调式时需要出力的信息。

                3,Error/Event Log:这两种绑定处理,错误处理。

 

        (四):配置文件:

        <configSections>
              <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
             </configSections>
             <loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="General"  logWarningsWhenNoCategoriesMatch="true">
                  <listeners>
                           <add fileName="log/debug.log" name="DebugListener" />
                           <add fileName="log/error.log"   name="ErrorListener" />
                           <add fileName="log/trace.log"   name="TraceListener" />
                           <add source="Log" formatter="Text Formatter" name="Formatted EventLog TraceListener" />
                  </listeners>
                  <formatters></formatters>
                  <categorySources>
                           <add switchValue="All" name="ErrorCategory">
                               <listeners>
                                     <add name="ErrorListener" />
                                     <add name="Formatted EventLog TraceListener" />
                                </listeners>
                           </add>
                           <add switchValue="All" name="DebugCategory">
                                <listeners>
                                     <add name="DebugListener" />
                                </listeners>
                           </add>
                           <add switchValue="All" name="TraceCategory">
                                <listeners>
                                     <add name="TraceListener" />
                                </listeners>
                           </add>
                  </categorySources>
                  <specialSources>   
                           <notProcessed switchValue="All" name="Unprocessed Category" />
                           <errors switchValue="All" name="Logging Errors &amp; Warnings">
                               <listeners>
                                     <add name="Formatted EventLog TraceListener" />
                                </listeners>
                           </errors>
                  </specialSources>
             </loggingConfiguration>

                

         

 

        

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值