Link
Exception display
In addition to the record function, the system exception module also has an important function: exception display, that is, what page is displayed to the user after a system exception occurs. Displaying a user friendly page is required as follows:
● Display to user-friendly pages can reduce user anxiety and improve user experience.
● Hide system exceptions to avoidCode, Path and other technical information leakage, improve system security.
● Unified management of system running exceptions helps improve the overall quality of software and facilitate overall control.
The display type of the friendly page is also based on the configuration node information. The Administrator only needs to change the enumeration value in the configuration node to change the user experience page. There are 10 methods on the user experience page, these methods are used to throw the original exception information, throw custom exception information, throw simple information (excluding exceptions), and hide exception information.
In the system development phase, you can display the original exception information. After the system is deployed, you can throw simple information (excluding exceptions) or hide the exception information, you can also choose whether to log to the log media when you select these display methods.
The configuration information of various exception presentations is as follows:
Code
Try
{
String I = " I " ;
Response. Write (I );
}
Catch (Exception ex)
{
Ilexception Ile = New Ilexception ();
Ile. writelog (Ex );
}
The "I" string is displayed on the normal access page. If the code is modified as follows, an error occurs:
Code
Try
{
String I = " I " ;
Response. Write (convert. toint32 (I ));
}
Catch (Exception ex)
{
Ilexception Ile = New Ilexception ();
Ile. writelog (Ex );
}
The page is displayed according to the following configuration information. The display mode is determined by the key value given by web. config:
<Add key = "isline. exceptionprocess. configuration. processstyle" value = "throworiginalwithlog"/>
The value can be the following enumerated values:
- Throworiginalwithlog
This method means to throw the original error and terminate the application.ProgramAnd record the error to the exception log.
Figure 1 original error
2. throworiginalwithoutlog
This method only throws the original error, terminates the application, and does not record this error, as shown in the figure above.
3. throwfriendlywithlog
This method means to throw a friendly error message, terminate the application, and record exceptions. The friendly exception information is defined by yourself.
Figure 2 Throw friendly Information
4. throwfriendlywithoutlog
The meaning of this method is to throw a friendly error message and terminate the application without recording exceptions, as shown in the figure above.
Note that you need to add additional node information in Web. config using the 3 and 4 configurations. The information determines the display field and layout of friendly information:
Add the following information to <configsections> </configsections>:
< Sectiongroup name = " Isline. exceptionprocess. Configuration " >
< Section name = " Ilexceptionmodel " Type = " Isline. Data. configuration. suitconfig " />
</ Sectiongroup >
Add the following information between </configsections> <appsettings>:
Code
< Isline. exceptionprocess. Configuration >
< Ilexceptionmodel >
< Message > -& GT; message: @ message </ Message >
< Level > -& GT; Level: @ level </ Level >
< Helplink > -& GT; helper: @ helplink </ Helplink >
< Source > -& GT; Source: @ Source </ Source >
< Stacktrace > -& GT; stack trace: @ stacktrace </ Stacktrace >
< Targetsite > -& GT; trigger: @ targetsite </ Targetsite >
< Hresult > -& GT; Result code: @ hresult </ Hresult >
< Eventdate > -& GT; Event Date: @ eventdate </ Eventdate >
< Otherplus > -& GT; contact method: </ Otherplus >
</ Ilexceptionmodel >
</ Isline. exceptionprocess. Configuration >
5. throwsimplewithlog
This method throws a simple predefined error message, terminates the application, and records exceptions.
Figure 3 throw simple predefined information
The predefined information is defined by the following nodes. The value part is the information displayed on the page:
<Add key = "isline. exceptionprocess. exceptionprocessprovider. friendlysimpletext" value = "the current page has an exception! "/>
6. throwsimplewithoutlog
The meaning of this method is to throw a simple predefined error message, terminate the application, and do not record exceptions, as shown in the figure above.
7. showsimplewithlog
This method means to display simple predefined error messages, do not terminate the application, and record exceptions.
The error message displayed in this mode is the same as that displayed in step 5 and step 6, but is configured in step 5 and Step 6. If an error occurs in the program, throw is triggered, leading to program termination; how can I display errors on 7 and 8, and the program continues to run.
8. showsimplewithoutlog
This method means to display simple predefined error messages without terminating the application or recording exceptions.
9. hidewithlog
This method means that no error information is displayed, the application is not terminated, and the exception information is recorded.
10. hidewithoutlog
This method means that no error information is displayed, no application is terminated, and no exception information is recorded.
Note that the log module can be understood as the inheritance relationship, and the Log Module's cache and other feature configurations are still valid in the exception.
As for the exception information, as we mentioned earlier, it is determined by the log render:
<Add key = "isline. exceptionprocess. configuration. rendername" value = "oracleusingsprender"/>
"Oracleusingsprender" is the log render name. The render model describes the location and format of exception records. For details, see
The third point in the exceptionprocessprovider exception framework (I.
Super exception log
If an error occurs during the exception record process, the exception information will not be recorded successfully, and the exception information will be ignored automatically. If the administrator wants to record the error in the log module, ilfw still records the information, the administrator can enable the "super log" switch in the configuration file.
When this switch is enabled, if the Log Module encounters an error (for example, database connection is interrupted), ilfw automatically records the current information to a text file until the cause of the Log Module error disappears.
Add the following nodes to Web. config to enable the super log function:
<Add key = "isline. exceptionprocess. exceptionprocessprovider. isopendebuginfo" value = "true"/>
The following nodes indicate the location of the Super log record:
<Add key = "isline. exceptionprocess. exceptionprocessprovider. debuginfo" value = "C: \ islinelog \ finallylog.txt"/>
Note: Super logs can only be written to text files. To use super logs, make sure that the relevant account has full control permissions on log files.
I amLi MingWelcome to my next articleArticle.