Log

xiaoxiao2021-03-06  50

Web event log

Web Event Logs to write event logs for web programs is a daily very needed feature. Here, you will pay attention to: First, you must handle Global.asax / ErrorGlobal.asaxprotaced Void Application_ERROR (Object Sender, Eventargs E) {string err = "SchoolWeb Application error / n / n "; Err =" Request: " Request.url.toString () " / n / n "; Err =" strack trace: / n " server.getlasterror (). Tostring ); Systemframeworks.error.log (ERR);} Second to pay attention to IIS privilege: // To assign write access to IIS in the registry system log to IIS, 2003 To change the registration table: hkey_local_machine / system / currentControlSet / Services / EVENTLOGHKEY_LOCAL_MACHINE / SYSTEM / CURRENTCONTROLSET / SERVICES / EVENTLOG On this button - "Permission Point" Add "then" Advanced "-" "Find Now" There is "IIS_WPG" user, add, then this permission is not good Use Machine.config to change username = "machine" password = "autogenerate" to username = "system" password = "autogenerate" finally writing a class to uniform processing: / using system; use system.diagnostics; namespace Winxiyu . DataAccess {////

/// ErrorClass summary description. /// public class errorclass {const string Event_log_source = ".NET COSTAR"; /// /// Log Message to Application Log. /// /// Message to log public static void log (string message) {EventLog m_eventLog = null;. // make sure we have an event log if {EventLog ((EventLog.SourceExists (EVENT_LOG_SOURCE))!). CreateEventSource (EVENT_LOG_SOURCE, "Application");} if (m_eventLog == null) {m_eventLog = new EventLog ( "Application"); m_eventLog.Source = EVENT_LOG_SOURCE;} // log the message m_eventLog.WriteEntry (message, System.Diagnostics. EventLoGENTRYTYPE.ERROR);}}}

转载请注明原文地址:https://www.9cbs.com/read-116465.html

New Post(0)