I am running this Blog to help other guys, who are looking some bits and pieces in terms of MS technology....
Thursday, September 17, 2009
EventLog Cycle (Provides interaction with Windows event logs.)
Introduction
Following are the important classes in Diagnostics namespace.
System.Diagnostics.EventLog
This component provides functionality to write to event logs, read event log entries, and create and delete event logs and event sources on the network.
Some related classes:
• EventLog: Provides interaction with Windows event logs
• EventLogEntry: Encapsulates a single record in the event log. This class cannot be inherited.
• EventLogEntryCollection: Defines size and enumerators for a collection of EventLogEntry instances
• EventLogInstaller: Allows you to install and configure an event log that your application reads from or writes to when running. This class is called by the installation utility, for example, InstallUtil.exe, when installing an event log.
• EventLogPermission: Allows control of code access permissions for event logging.
• EventLogPermissionAttribute: Allows declarative permission checks for event logging
• EventLogPermissionEntry: Defines the smallest unit of a code access security permission that is set for an EventLog
• EventLogPermissionEntryCollection: Contains a strongly typed collection of EventLogPermissionEntry objects
• EventLogTraceListener: Provides a simple listener that directs tracing or debugging output to an EventLog
Examples: follow steps those are required to complete the eventlog process
1)Initialize Log component
private System.Diagnostics.EventLog eventLog1;
this.eventLog1 = new System.Diagnostics.EventLog();
((System.ComponentModel.ISupportInitialize)(this.eventLog1)).BeginInit();
this.ServiceName = "Your Service Name";
((System.ComponentModel.ISupportInitialize)(this.eventLog1)).EndInit();
2)Create a source name and log name, which showing in system event log
if (!System.Diagnostics.EventLog.SourceExists("Log Source Name"))
{
System.Diagnostics.EventLog.CreateEventSource("Log Source Name", "Log Root Name");
}
eventLog1.Source = "Log Source Name";
eventLog1.Log = "Log Root Name";
3)How to write an error in defined source log
catch (Exception ex)
{
eventLog1.WriteEntry("Error :" +
ex.Message + "--" +
ex.StackTrace, System.Diagnostics.EventLogEntryType.Error);
Alert(ex);
}
Subscribe to:
Post Comments (Atom)
Split the String values with a special character in MS Flow to convert this into Array
Many times we have a requirement to prepare the Mailing address for some of the documents, suppose there are Address Line1, Address Line2, ...
-
Use the following line of code to Reopen the closed task in CRM 2011 // Re-open the Task to update it SetStateRequest ssr = new SetStat...
-
Use the following line of code to create complete workflow activity with two output parameters. 1) Open Visual Studio 2010 ID. 2) Open ...
-
Sometimes you experienced when you have subgrid in your CRM Form, but when you click the ‘expand’ button to expand the view then it will re...
No comments:
Post a Comment