About us |  Help us improve
intelliVERB - Get a fair search of the Internet !
Visual studio .net
SQL Server
Oracle
Main  >  Server components  >  Event log Email this page to friend
Event log
 
 
 
 
 
C#Using system event logTop
Using system event log
Using System.Diagnostics;
namespace SCP
{
 public class UseEventLog
 {
  private EventLog Log1;
  /// <summary>
  /// The Event source will be register with the local computer
  /// </summary>
  /// <param name="SourceName"></param>
  /// <param name="LogName"></param>
  
public UseEventLog(string SourceName,string LogName)
  {
   Log1=new EventLog();
   //check if an event log already exists for this source
   if (EventLog.SourceExists(SourceName)== false)
   {
    /*
For LogName: Application, Security, System, or a custom event log can be use.
If you do not specify a value, the logName defaults to Application.
    */

EventLog.CreateEventSource(SourceName,LogName);
   }
   //set SourceName as source for Log1
   Log1.Source=SourceName;
  }
  /// <summary>
  /// This overload of UseEventLog uses
/// MachineName: The name of the computer to register the event source with.
  /// "." can be specify for the local computer.
  /// </summary>

public UseEventLog(string SourceName,string LogName,string MachineName)
  {
   Log1=new EventLog();
   //check if an event log already exists for this source
   if (EventLog.SourceExists(SourceName,MachineName)==false)
   {
    /*
    For LogName: Application, Security, System, or a custom event log can be use.
    If you do not specify a value, the logName defaults to Application.
    */

      EventLog.CreateEventSource(SourceName,LogName,MachineName);
   }
   //set SourceName as source for Log1
   Log1.Source=SourceName;
  }
 }
 public void LogMessage(string Message)
 {
  Log1.WriteEntry(Message);
 }
}
You last visited
Triggers Oracle
Windows service
DDL Oracle
Oracle basic functions
Remoting
Web Objects
Inheritance C# .net
XML
Assemblies
DDL Sql Server
Sql Server Basic functions
COM +
DML Sql Server
 
 
Make a secure donation now with PayPal!