error page is issued only when a remote browser clicks the site (the developer clicking the site on the actual machine sees the detailed error information ).
2. Add the application error code to the Global. asax file and write it to the system log file.
CodeProtected void application_error (Object sender, eventargs E){Exception lasterror = server. getlasterror ();String errmessage = lasterror. tostring ();
String LOGNAME = "mylog ";String message = "url" + request. Path + "error:" + errmessag
application_error in the global. asax file. You can add other operations, such as writing Windows event logs, sending emails to administrators, and writing error information to the database. Details: 1 protected void application_error (Object sender, eventargs E)2 {3 string message = "\ n \ nurl: \ n http: // localhost/" + request. Path4 + "\ n \ nmessage: \ n" + server. getlasterror (). Message5 + "\ n \ nstack trace: \ n" + server. getlasterror (). stacktrace;6 // write windows Event Logs7 st
is sometimes impossible to estimate all exceptions. In this way, once such exceptions occur, the yellow pages will be displayed, Which is unfriendly, it is convenient to define exceptions in application_error events.Protected void application_error (Object sender, eventargs E){String LOGNAME = "web_error ";String message = "";Message = "url:" + request. Path + "; error:" + server. getlasterror (). tostring ();
// Check whether the log existsIf (! EventLog
application_error in the global. asax file. You can add other operations, such as writing Windows event logs, sending emails to administrators, and writing error information to the database. Details: 1 protected void application_error (Object sender, eventargs E)2 {3 string message = "\ n \ nurl: \ n http: // localhost/" + request. Path4 + "\ n \ nmessage: \ n" + server. getlasterror (). Message5 + "\ n \ nstack trace: \ n" + server. getlasterror (). stacktrace;6 // write windows Event Logs7 st
Custom Event Log to the Windows service. Event Logs are not associated with Windows Services in any form. The EventLog component can be used to add
Example of the component type added to the Windows service.
2. Add the Custom Event Log feature to the service.
In Solution Explorer, right-click service1.cs and select View designer ".On the components tab of the Toolkit, drag the EventLog component to the des
. Remove ("loginnamevalidate ");}Catch{}Finally{// Depending on the situation, determine whether to exit the program and add session. removeall ();}}}-----------------------------------------------3. An error is recorded in the system application error log instance:Add to globalv. asax. CSProtected void application_error (Object sender, eventargs E){// Record the error to the system log. Import the system. Diagnostics namespace.// [HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \
:
Close the preceding window and process window.
Use the File menu of vs.net to open the user control file authorswebserviceclient. CS and set breakpoints in the source code. In this way, once you set a breakpoint, You can debug the control, as shown in.
Windows form code access permission
As we have discussed before. When the Form Control is executed in IE, it uses the permissions provided by. Net runtime. To understand how to use the code access security provided by the. NET runtime to run
In Asp.net, when a server error occurs, the specified error page is displayed and the error information is written into the system log file.
1. Enter the page displayed when an error occurs in Web. config. Different error pages can be displayed based on different statuscode.
ProgramCode
2. Add the application error code to the Global. asax file and write it to the system log file.
Program codeProtected void application_error (Object sender, eventargs E){Exception lasterror = server. getl
declarative error handling performed for the application is as follows:
Customerrors
Defaultredirect
= "Url"
Mode
= "Remoteonly"
>
Error
Statuscode
= "Code"
Redirect
= "Url"
>
Error
>
Customerrors
>
When a page error occurs, the application should also let the administrator or developer know when and where an error occurs. Generally, there are two methods.
1. Write events to Event Log
Imports
System. Diagnostics
Sub application_error
A small one recently madeProgram(Windows Console). If it is not very large, write the error messageEXE. configBut read from the programConfigFromConfigThe carriage return sign ("N) Is not correctly parsed and found only during debugging,"N"All are automatically replaced"N". I don't know why..... 0 (>_
Later"N"Change" #10 ;"Can be parsed normally. (Thanks to the guidance of our predecessors)
CodeImplementation
ConfigFields in
CSFile Code
//Save to ApplicationLog
String log_name = "a
named "love" existsIf (! EventLog. sourceexists (c_eventsource )){// Try to create an object if it does not existEventLog. createeventsource (c_eventsource, c_logname );}// Already exists. Write the error message to the logEventLog MSG = new EventLog (c_logname );MSG. Source = c_eventsource;MSG. writeentry (errormessage, eventlogentrytype. Error );}Catch{}}}7. O
class EventLog is provided in the. NET Framework, and you can use the EventLog class to add new event log entries or get existing entries from the server event log. The EventLog class includes a WriteEntry () method that you can use to write a new event to the event log. When a new entry is written to the event log, the entry is written to a specific event log u
Label:I. Preface In our operating system, sometimes to unload the Oracle database, each time to remove the win under the registry, in order to facilitate the removal of the registry information, the following through a delete registry shortcut script. Two. Scripting information Windows Registry Editor Version 5.00 [-hkey_local_machine\software\oracle] [-HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\ODP. NET] [-hkey_current_user\software\microsoft\windows\currentversion\explorer\menuorder\startmenu\programs
Permissions for the event log are driven through the registry. Each event log has an entry in the registry under the following key:
HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ EventLog
To allow the ASP. net account access to create an event source, you need to have read permission on this and all sub keys, and write permission on the event to which you want to create the event source. part of your error message says "inaccessible log
Summary of this chapter:
1:trace and Debug differences
2: What is listeners
3: Tracking Switch
3.1: Use BooleanSwitch switch
3.2: Use TraceSwitch switch
4: Use TraceSource instead of trace and
5: Design a log system
6: About EventLog
The. NET Framework namespace System.Diagnostics contains trace, Debug, and TraceSource classes for tracking execution processes, as well as Process, EventLog, and Performance
Label:The original: Remember the paging optimization of SQL Server and talk about the problems of using row_number () pageRecently there is a project response, in the server CPU usage is high, our Event query page is very slow, query a few records unexpectedly 4 minutes or more, and in the second page to take so much time, this is certainly unacceptable, but also let the scene with SQLServerProfiler the statement grabbed up.Paging with Row_number ()Let's take a look at the page statements caught
Label:Recently there is a project response, in the server CPU usage is high, our Event query page is very slow, query a few records unexpectedly 4 minutes or more, and in the second page to take so much time, this is certainly unacceptable, but also let the scene with SQLServerProfiler the statement grabbed up.Paging with Row_number ()Let's take a look at the page statements caught at the scene: select top A.*,ag. Name as agentservername,,d.name as mgrobjtypename,l.username as UserName from
the paging statements captured at the site:
select top 20 a.*,ag.Name as AgentServerName,,d.Name as MgrObjTypeName,l.UserName as userName from eventlog as a left join mgrobj as b on a.MgrObjId=b.Id and a.AgentBm=b.AgentBm left join addrnode as c on b.AddrId=c.Id left join mgrobjtype as d on b.MgrObjTypeId=d.Id left join eventdir as e on a.EventBm=e.Bm left join agentserver as ag on a.AgentBm=ag.AgentBm left join loginUser as l on a.cfmoper=l.loginGui
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.