2 using Microsoft.Win32.SafeHandles;
17 [DefaultEvent(
"EntryWritten")]
18 [InstallerType(
"System.Diagnostics.EventLogInstaller, System.Configuration.Install, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
19 [MonitoringDescription(
"EventLogDesc")]
22 private const string EventLogKey =
"SYSTEM\\CurrentControlSet\\Services\\EventLog";
24 internal const string DllName =
"EventLogMessages.dll";
26 private const string eventLogMutexName =
"netfxeventlog.1.0";
28 private const int DefaultMaxSize = 524288;
30 private const int DefaultRetention = 604800;
32 private const int SecondsPerDay = 86400;
34 private EventLogInternal m_underlyingEventLog;
36 private static volatile bool s_CheckedOsVersion;
38 private static volatile bool s_SkipRegPatch;
40 private static bool SkipRegPatch
44 if (!s_CheckedOsVersion)
48 s_CheckedOsVersion =
true;
50 return s_SkipRegPatch;
58 [MonitoringDescription(
"LogEntries")]
63 return m_underlyingEventLog.Entries;
75 return m_underlyingEventLog.LogDisplayName;
81 [
TypeConverter(
"System.Diagnostics.Design.LogConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
83 [MonitoringDescription(
"LogLog")]
85 [SettingsBindable(
true)]
90 return m_underlyingEventLog.Log;
94 EventLogInternal eventLogInternal =
new EventLogInternal(value, m_underlyingEventLog.MachineName, m_underlyingEventLog.Source,
this);
95 EventLogInternal underlyingEventLog = m_underlyingEventLog;
97 if (underlyingEventLog.EnableRaisingEvents)
99 eventLogInternal.onEntryWrittenHandler = underlyingEventLog.onEntryWrittenHandler;
100 eventLogInternal.EnableRaisingEvents =
true;
102 m_underlyingEventLog = eventLogInternal;
103 underlyingEventLog.Close();
111 [MonitoringDescription(
"LogMachineName")]
113 [SettingsBindable(
true)]
118 return m_underlyingEventLog.MachineName;
122 EventLogInternal eventLogInternal =
new EventLogInternal(m_underlyingEventLog.logName, value, m_underlyingEventLog.sourceName,
this);
123 EventLogInternal underlyingEventLog = m_underlyingEventLog;
125 if (underlyingEventLog.EnableRaisingEvents)
127 eventLogInternal.onEntryWrittenHandler = underlyingEventLog.onEntryWrittenHandler;
128 eventLogInternal.EnableRaisingEvents =
true;
130 m_underlyingEventLog = eventLogInternal;
131 underlyingEventLog.Close();
146 return m_underlyingEventLog.MaximumKilobytes;
150 m_underlyingEventLog.MaximumKilobytes = value;
162 return m_underlyingEventLog.OverflowAction;
174 return m_underlyingEventLog.MinimumRetentionDays;
178 internal bool ComponentDesignMode => base.DesignMode;
185 [MonitoringDescription(
"LogMonitoring")]
186 [DefaultValue(
false)]
191 return m_underlyingEventLog.EnableRaisingEvents;
195 m_underlyingEventLog.EnableRaisingEvents = value;
203 [MonitoringDescription(
"LogSynchronizingObject")]
209 return m_underlyingEventLog.SynchronizingObject;
213 m_underlyingEventLog.SynchronizingObject = value;
221 [
TypeConverter(
"System.Diagnostics.Design.StringValueConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
222 [MonitoringDescription(
"LogSource")]
224 [SettingsBindable(
true)]
229 return m_underlyingEventLog.Source;
233 EventLogInternal eventLogInternal =
new EventLogInternal(m_underlyingEventLog.Log, m_underlyingEventLog.MachineName, CheckAndNormalizeSourceName(value),
this);
234 EventLogInternal underlyingEventLog = m_underlyingEventLog;
236 if (underlyingEventLog.EnableRaisingEvents)
238 eventLogInternal.onEntryWrittenHandler = underlyingEventLog.onEntryWrittenHandler;
239 eventLogInternal.EnableRaisingEvents =
true;
241 m_underlyingEventLog = eventLogInternal;
242 underlyingEventLog.Close();
247 [MonitoringDescription(
"LogEntryWritten")]
252 m_underlyingEventLog.EntryWritten += value;
256 m_underlyingEventLog.EntryWritten -= value;
269 return permissionSet;
283 : this(logName,
".",
"")
292 public EventLog(
string logName,
string machineName)
293 : this(logName, machineName,
"")
303 public EventLog(
string logName,
string machineName,
string source)
305 m_underlyingEventLog =
new EventLogInternal(logName, machineName, source,
this);
308 internal object ComponentGetService(
Type service)
318 m_underlyingEventLog.BeginInit();
327 m_underlyingEventLog.Clear();
334 m_underlyingEventLog.Close();
359 [Obsolete(
"This method has been deprecated. Please use System.Diagnostics.EventLog.CreateEventSource(EventSourceCreationData sourceData) instead. http://go.microsoft.com/fwlink/?linkid=14202")]
373 if (sourceData ==
null)
377 string text = sourceData.
LogName;
378 string source = sourceData.
Source;
382 throw new ArgumentException(SR.GetString(
"InvalidParameter",
"machineName", machineName));
384 if (text ==
null || text.Length == 0)
386 text =
"Application";
388 if (!ValidLogName(text, ignoreEmpty:
false))
392 if (source ==
null || source.Length == 0)
396 if (source.Length +
"SYSTEM\\CurrentControlSet\\Services\\EventLog".Length > 254)
398 throw new ArgumentException(SR.GetString(
"ParameterTooLong",
"source", 254 -
"SYSTEM\\CurrentControlSet\\Services\\EventLog".Length));
401 eventLogPermission.
Demand();
406 SharedUtils.EnterMutex(
"netfxeventlog.1.0", ref mutex);
407 if (
SourceExists(source, machineName, wantToCreate:
true))
409 if (
".".Equals(machineName))
413 throw new ArgumentException(SR.GetString(
"SourceAlreadyExists", source, machineName));
417 RegistryKey registryKey =
null;
418 RegistryKey registryKey2 =
null;
419 RegistryKey registryKey3 =
null;
420 RegistryKey registryKey4 =
null;
421 RegistryKey registryKey5 =
null;
424 registryKey = ((!(machineName ==
".")) ? RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, machineName) : Registry.LocalMachine);
425 registryKey2 = registryKey.OpenSubKey(
"SYSTEM\\CurrentControlSet\\Services\\EventLog", writable:
true);
426 if (registryKey2 ==
null)
428 if (!
".".Equals(machineName))
430 throw new InvalidOperationException(SR.GetString(
"RegKeyMissing",
"SYSTEM\\CurrentControlSet\\Services\\EventLog", text, source, machineName));
432 throw new InvalidOperationException(SR.GetString(
"LocalRegKeyMissing",
"SYSTEM\\CurrentControlSet\\Services\\EventLog", text, source));
434 registryKey3 = registryKey2.OpenSubKey(text, writable:
true);
435 if (registryKey3 ==
null && text.Length >= 8)
437 string strA = text.Substring(0, 8);
442 string text2 = FindSame8FirstCharsLog(registryKey2, text);
448 bool flag = registryKey3 ==
null;
451 if (
SourceExists(text, machineName, wantToCreate:
true))
453 if (
".".Equals(machineName))
455 throw new ArgumentException(SR.GetString(
"LocalLogAlreadyExistsAsSource", text));
457 throw new ArgumentException(SR.GetString(
"LogAlreadyExistsAsSource", text, machineName));
459 registryKey3 = registryKey2.CreateSubKey(text);
462 registryKey3.SetValue(
"Sources",
new string[2]
466 }, RegistryValueKind.MultiString);
468 SetSpecialLogRegValues(registryKey3, text);
469 registryKey4 = registryKey3.CreateSubKey(text);
470 SetSpecialSourceRegValues(registryKey4, sourceData);
476 SetSpecialLogRegValues(registryKey3, text);
479 string[] array = registryKey3.GetValue(
"Sources") as
string[];
482 registryKey3.SetValue(
"Sources",
new string[2]
486 }, RegistryValueKind.MultiString);
488 else if (
Array.IndexOf(array, source) == -1)
490 string[] array2 =
new string[array.Length + 1];
492 array2[array.Length] = source;
493 registryKey3.SetValue(
"Sources", array2, RegistryValueKind.MultiString);
497 registryKey5 = registryKey3.CreateSubKey(source);
498 SetSpecialSourceRegValues(registryKey5, sourceData);
503 registryKey?.Close();
504 registryKey2?.Close();
505 if (registryKey3 !=
null)
507 registryKey3.Flush();
508 registryKey3.Close();
510 if (registryKey4 !=
null)
512 registryKey4.Flush();
513 registryKey4.Close();
515 if (registryKey5 !=
null)
517 registryKey5.Flush();
518 registryKey5.Close();
539 public static void Delete(
string logName)
552 public static void Delete(
string logName,
string machineName)
556 throw new ArgumentException(SR.GetString(
"InvalidParameterFormat",
"machineName"));
558 if (logName ==
null || logName.Length == 0)
562 if (!ValidLogName(logName, ignoreEmpty:
false))
567 eventLogPermission.
Demand();
568 SharedUtils.CheckEnvironment();
571 RegistryKey registryKey =
null;
576 SharedUtils.EnterMutex(
"netfxeventlog.1.0", ref mutex);
579 registryKey = GetEventLogRegKey(machineName, writable:
true);
580 if (registryKey ==
null)
582 throw new InvalidOperationException(SR.GetString(
"RegKeyNoAccess",
"HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\EventLog", machineName));
584 using (RegistryKey registryKey2 = registryKey.OpenSubKey(logName))
586 if (registryKey2 ==
null)
602 text = (string)registryKey2.GetValue(
"File");
618 registryKey.DeleteSubKeyTree(logName);
622 registryKey?.Close();
650 throw new ArgumentException(SR.GetString(
"InvalidParameter",
"machineName", machineName));
653 eventLogPermission.
Demand();
654 SharedUtils.CheckEnvironment();
661 SharedUtils.EnterMutex(
"netfxeventlog.1.0", ref mutex);
662 RegistryKey registryKey =
null;
663 using (registryKey = FindSourceRegistration(source, machineName, readOnly:
true))
665 if (registryKey ==
null)
667 if (machineName ==
null)
671 throw new ArgumentException(SR.GetString(
"SourceNotRegistered", source, machineName,
"HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\EventLog"));
673 string name = registryKey.Name;
674 int num = name.LastIndexOf(
'\\');
675 if (
string.Compare(name, num + 1, source, 0, name.Length - num,
StringComparison.Ordinal) == 0)
682 registryKey = FindSourceRegistration(source, machineName, readOnly:
false);
683 registryKey.DeleteSubKeyTree(source);
686 string[] array = (
string[])registryKey.GetValue(
"Sources");
688 for (
int i = 0; i < array.Length; i++)
690 if (array[i] != source)
692 arrayList.
Add(array[i]);
695 string[] array2 =
new string[arrayList.
Count];
697 registryKey.SetValue(
"Sources", array2, RegistryValueKind.MultiString);
702 if (registryKey !=
null)
719 protected override void Dispose(
bool disposing)
721 if (m_underlyingEventLog !=
null)
723 m_underlyingEventLog.Dispose(disposing);
725 base.Dispose(disposing);
731 m_underlyingEventLog.EndInit();
739 public static bool Exists(
string logName)
741 return Exists(logName,
".");
750 public static bool Exists(
string logName,
string machineName)
754 throw new ArgumentException(SR.GetString(
"InvalidParameterFormat",
"machineName"));
757 eventLogPermission.
Demand();
758 if (logName ==
null || logName.Length == 0)
762 SharedUtils.CheckEnvironment();
765 RegistryKey registryKey =
null;
766 RegistryKey registryKey2 =
null;
769 registryKey = GetEventLogRegKey(machineName, writable:
false);
770 if (registryKey ==
null)
774 registryKey2 = registryKey.OpenSubKey(logName, writable:
false);
775 return registryKey2 !=
null;
779 registryKey?.Close();
780 registryKey2?.Close();
785 private static string FindSame8FirstCharsLog(RegistryKey keyParent,
string logName)
787 string strB = logName.Substring(0, 8);
788 string[] subKeyNames = keyParent.GetSubKeyNames();
789 foreach (
string text
in subKeyNames)
791 if (text.Length >= 8 &&
string.Compare(text.Substring(0, 8), strB,
StringComparison.OrdinalIgnoreCase) == 0)
799 private static RegistryKey FindSourceRegistration(
string source,
string machineName,
bool readOnly)
801 return FindSourceRegistration(source, machineName, readOnly, wantToCreate:
false);
804 private static RegistryKey FindSourceRegistration(
string source,
string machineName,
bool readOnly,
bool wantToCreate)
806 if (source !=
null && source.Length != 0)
808 SharedUtils.CheckEnvironment();
814 registryKey = GetEventLogRegKey(machineName, !readOnly);
815 if (registryKey ==
null)
820 string[] subKeyNames = registryKey.GetSubKeyNames();
821 for (
int i = 0; i < subKeyNames.Length; i++)
826 RegistryKey registryKey3 = registryKey.OpenSubKey(subKeyNames[i], !readOnly);
827 if (registryKey3 !=
null)
829 registryKey2 = registryKey3.OpenSubKey(source, !readOnly);
830 if (registryKey2 !=
null)
834 registryKey3.Close();
837 catch (UnauthorizedAccessException)
839 if (stringBuilder ==
null)
845 stringBuilder.
Append(
", ");
846 stringBuilder.
Append(subKeyNames[i]);
851 if (stringBuilder ==
null)
857 stringBuilder.
Append(
", ");
858 stringBuilder.
Append(subKeyNames[i]);
863 registryKey2?.Close();
866 if (stringBuilder !=
null)
868 throw new SecurityException(SR.GetString(wantToCreate ?
"SomeLogsInaccessibleToCreate" :
"SomeLogsInaccessible", stringBuilder.
ToString()));
873 registryKey?.Close();
897 throw new ArgumentException(SR.GetString(
"InvalidParameter",
"machineName", machineName));
900 eventLogPermission.
Demand();
901 SharedUtils.CheckEnvironment();
902 string[] array =
new string[0];
905 RegistryKey registryKey =
null;
908 registryKey = GetEventLogRegKey(machineName, writable:
false);
909 if (registryKey ==
null)
911 throw new InvalidOperationException(SR.GetString(
"RegKeyMissingShort",
"SYSTEM\\CurrentControlSet\\Services\\EventLog", machineName));
913 array = registryKey.GetSubKeyNames();
917 registryKey?.Close();
921 for (
int i = 0; i < array.Length; i++)
928 internal static RegistryKey GetEventLogRegKey(
string machine,
bool writable)
930 RegistryKey registryKey =
null;
933 registryKey = ((!machine.Equals(
".")) ? RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, machine) : Registry.LocalMachine);
934 if (registryKey !=
null)
936 return registryKey.OpenSubKey(
"SYSTEM\\CurrentControlSet\\Services\\EventLog", writable);
941 registryKey?.Close();
946 internal static string GetDllPath(
string machineName)
948 return Path.
Combine(SharedUtils.GetLatestBuildDllDirectory(machineName),
"EventLogMessages.dll");
973 return SourceExists(source, machineName, wantToCreate:
false);
976 internal static bool SourceExists(
string source,
string machineName,
bool wantToCreate)
980 throw new ArgumentException(SR.GetString(
"InvalidParameter",
"machineName", machineName));
983 eventLogPermission.Demand();
984 using (RegistryKey registryKey = FindSourceRegistration(source, machineName, readOnly:
true, wantToCreate))
986 return registryKey !=
null;
997 eventLogPermission.
Demand();
998 return _InternalLogNameFromSourceName(source, machineName);
1001 internal static string _InternalLogNameFromSourceName(
string source,
string machineName)
1003 using (RegistryKey registryKey = FindSourceRegistration(source, machineName, readOnly:
true))
1005 if (registryKey ==
null)
1009 string name = registryKey.Name;
1010 int num = name.LastIndexOf(
'\\');
1011 return name.Substring(num + 1);
1026 m_underlyingEventLog.ModifyOverflowPolicy(action, retentionDays);
1038 m_underlyingEventLog.RegisterDisplayName(resourceFile, resourceId);
1041 private static void SetSpecialLogRegValues(RegistryKey logKey,
string logName)
1043 if (logKey.GetValue(
"MaxSize") ==
null)
1045 logKey.SetValue(
"MaxSize", 524288, RegistryValueKind.DWord);
1047 if (logKey.GetValue(
"AutoBackupLogFiles") ==
null)
1049 logKey.SetValue(
"AutoBackupLogFiles", 0, RegistryValueKind.DWord);
1053 if (logKey.GetValue(
"Retention") ==
null)
1055 logKey.SetValue(
"Retention", 604800, RegistryValueKind.DWord);
1057 if (logKey.GetValue(
"File") ==
null)
1059 string value = (logName.Length <= 8) ? (
"%SystemRoot%\\System32\\config\\" + logName +
".evt") : (
"%SystemRoot%\\System32\\config\\" + logName.Substring(0, 8) +
".evt");
1060 logKey.SetValue(
"File", value, RegistryValueKind.ExpandString);
1065 private static void SetSpecialSourceRegValues(RegistryKey sourceLogKey, EventSourceCreationData sourceData)
1067 if (
string.IsNullOrEmpty(sourceData.MessageResourceFile))
1069 sourceLogKey.SetValue(
"EventMessageFile", GetDllPath(sourceData.MachineName), RegistryValueKind.ExpandString);
1073 sourceLogKey.SetValue(
"EventMessageFile", FixupPath(sourceData.MessageResourceFile), RegistryValueKind.ExpandString);
1075 if (!
string.IsNullOrEmpty(sourceData.ParameterResourceFile))
1077 sourceLogKey.SetValue(
"ParameterMessageFile", FixupPath(sourceData.ParameterResourceFile), RegistryValueKind.ExpandString);
1079 if (!
string.IsNullOrEmpty(sourceData.CategoryResourceFile))
1081 sourceLogKey.SetValue(
"CategoryMessageFile", FixupPath(sourceData.CategoryResourceFile), RegistryValueKind.ExpandString);
1082 sourceLogKey.SetValue(
"CategoryCount", sourceData.CategoryCount, RegistryValueKind.DWord);
1086 private static string FixupPath(
string path)
1095 internal static string TryFormatMessage(Microsoft.Win32.SafeHandles.SafeLibraryHandle hModule, uint messageNum,
string[] insertionStrings)
1097 if (insertionStrings.Length == 0)
1099 return UnsafeTryFormatMessage(hModule, messageNum, insertionStrings);
1101 string text = UnsafeTryFormatMessage(hModule, messageNum,
new string[0]);
1107 for (
int i = 0; i < text.Length; i++)
1109 if (text[i] !=
'%' || text.Length <= i + 1)
1114 for (; i + 1 < text.Length &&
char.IsDigit(text[i + 1]); i++)
1116 stringBuilder.
Append(text[i + 1]);
1119 if (stringBuilder.
Length > 0)
1124 num = Math.Max(num, result);
1128 if (num > insertionStrings.Length)
1130 string[] array =
new string[num];
1131 Array.Copy(insertionStrings, array, insertionStrings.Length);
1132 for (
int j = insertionStrings.Length; j < array.Length; j++)
1134 array[j] =
"%" + (j + 1);
1136 insertionStrings = array;
1138 return UnsafeTryFormatMessage(hModule, messageNum, insertionStrings);
1141 internal static string UnsafeTryFormatMessage(Microsoft.Win32.SafeHandles.SafeLibraryHandle hModule, uint messageNum,
string[] insertionStrings)
1147 IntPtr[] array =
new IntPtr[insertionStrings.Length];
1150 if (insertionStrings.Length == 0)
1156 for (
int i = 0; i < array2.Length; i++)
1162 while (num == 0 && num3 == 122)
1164 num = Microsoft.Win32.SafeNativeMethods.FormatMessage(num2, hModule, messageNum, 0, stringBuilder, stringBuilder.
Capacity, array);
1181 for (
int j = 0; j < array2.Length; j++)
1183 if (array2[j].IsAllocated)
1193 if (text.Length > 1 && text[text.Length - 1] ==
'\n')
1195 text = text.Substring(0, text.Length - 2);
1201 private static bool CharIsPrintable(
char c)
1211 internal static bool ValidLogName(
string logName,
bool ignoreEmpty)
1213 if (logName.Length == 0 && !ignoreEmpty)
1217 foreach (
char c
in logName)
1219 if (!CharIsPrintable(c) || c ==
'\\' || c ==
'*' || c ==
'?')
1272 WriteEntry(source, message, type, 0, 0,
null);
1303 WriteEntry(source, message, type, eventID, 0,
null);
1319 WriteEntry(message, type, eventID, category,
null);
1336 WriteEntry(source, message, type, eventID, category,
null);
1354 using (EventLogInternal eventLogInternal =
new EventLogInternal(
"",
".", CheckAndNormalizeSourceName(source)))
1356 eventLogInternal.WriteEntry(message, type, eventID, category, rawData);
1374 m_underlyingEventLog.WriteEntry(message, type, eventID, category, rawData);
1407 m_underlyingEventLog.WriteEvent(instance, data, values);
1423 using (EventLogInternal eventLogInternal =
new EventLogInternal(
"",
".", CheckAndNormalizeSourceName(source)))
1425 eventLogInternal.WriteEvent(instance,
null, values);
1443 using (EventLogInternal eventLogInternal =
new EventLogInternal(
"",
".", CheckAndNormalizeSourceName(source)))
1445 eventLogInternal.WriteEvent(instance, data, values);
1449 private static string CheckAndNormalizeSourceName(
string source)
1453 source =
string.Empty;
1455 if (source.Length +
"SYSTEM\\CurrentControlSet\\Services\\EventLog".Length > 254)
1457 throw new ArgumentException(SR.GetString(
"ParameterTooLong",
"source", 254 -
"SYSTEM\\CurrentControlSet\\Services\\EventLog".Length));
static CultureInfo InvariantCulture
Gets the T:System.Globalization.CultureInfo object that is culture-independent (invariant).
void WriteEntry(string message)
Writes an information type entry, with the given message text, to the event log.
override void Dispose(bool disposing)
Releases the unmanaged resources used by the T:System.Diagnostics.EventLog, and optionally releases t...
static void WriteEvent(string source, EventInstance instance, params object[] values)
Writes an event log entry with the given event data and message replacement strings,...
PlatformID
Identifies the operating system, or platform, supported by an assembly.
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
string MachineName
Gets or sets the name of the computer on which to read or write events.
Describes a set of security permissions applied to code. This class cannot be inherited.
static string LogNameFromSourceName(string source, string machineName)
Gets the name of the log to which the specified source is registered.
static bool SourceExists(string source)
Determines whether an event source is registered on the local computer.
EntryWrittenEventHandler EntryWritten
Occurs when an entry is written to an event log on the local computer.
unsafe override string ToString()
Converts the value of this instance to a T:System.String.
static string Combine(string path1, string path2)
Combines two strings into a path.
void Clear()
Removes all entries from the event log.
string Source
Gets or sets the name to register with the event log as an event source.
StringComparison
Specifies the culture, case, and sort rules to be used by certain overloads of the M:System....
EventLog(string logName, string machineName)
Initializes a new instance of the T:System.Diagnostics.EventLog class. Associates the instance with a...
void WriteEntry(string message, EventLogEntryType type, int eventID, short category, byte[] rawData)
Writes an entry with the given message text, application-defined event identifier,...
Controls the ability to access registry variables. This class cannot be inherited.
string Source
Gets or sets the source name to register and use when writing to the event log.
void ReleaseMutex()
Releases the T:System.Threading.Mutex once.
Represents the configuration settings used to create an event log source on the local computer or a r...
EventLogEntryType
Specifies the event type of an event log entry.
virtual int Count
Gets the number of elements actually contained in the T:System.Collections.ArrayList.
EventLog(string logName)
Initializes a new instance of the T:System.Diagnostics.EventLog class. Associates the instance with a...
void Close()
Closes the event log and releases read and write handles.
static OperatingSystem OSVersion
Gets an T:System.OperatingSystem object that contains the current platform identifier and version num...
void WriteEvent(EventInstance instance, byte[] data, params object[] values)
Writes an event log entry with the given event data, message replacement strings, and associated bina...
A synchronization primitive that can also be used for interprocess synchronization.
static void WriteEvent(string source, EventInstance instance, byte[] data, params object[] values)
Writes an event log entry with the given event data, message replacement strings, and associated bina...
string LogDisplayName
Gets the event log's friendly name.
static void WriteEntry(string source, string message, EventLogEntryType type, int eventID)
Writes an entry with the given message text and application-defined event identifier to the event log...
Represents language-neutral information for an event log entry.
Provides a way to synchronously or asynchronously execute a delegate.
string MachineName
Gets or sets the name of the computer on which to register the event source.
static void WriteEntry(string source, string message, EventLogEntryType type)
Writes an error, warning, information, success audit, or failure audit entry with the given message t...
static void WriteEntry(string source, string message, EventLogEntryType type, int eventID, short category)
Writes an entry with the given message text, application-defined event identifier,...
void EndInit()
Ends the initialization of an T:System.Diagnostics.EventLog used on a form or by another component....
static EventLog [] GetEventLogs(string machineName)
Searches for all event logs on the given computer and creates an array of T:System....
void WriteEntry(string message, EventLogEntryType type, int eventID, short category)
Writes an entry with the given message text, application-defined event identifier,...
Version Version
Gets a T:System.Version object that identifies the operating system.
IPermission AddPermission(IPermission perm)
Adds a specified permission to the T:System.Security.PermissionSet.
NumberStyles
Determines the styles permitted in numeric string arguments that are passed to the Parse and TryParse...
ISynchronizeInvoke SynchronizingObject
Gets or sets the object used to marshal the event handler calls issued as a result of an T:System....
EventLogPermissionAccess
Defines access levels used by T:System.Diagnostics.EventLog permission classes.
PlatformID Platform
Gets a T:System.PlatformID enumeration value that identifies the operating system platform.
EventLog()
Initializes a new instance of the T:System.Diagnostics.EventLog class. Does not associate the instanc...
SecurityAction
Specifies the security actions that can be performed using declarative security.
Provides information about, and means to manipulate, the current environment and platform....
StringBuilder Append(char value, int repeatCount)
Appends a specified number of copies of the string representation of a Unicode character to this inst...
int Major
Gets the value of the major component of the version number for the current T:System....
Represents a collection that can contain many different types of permissions.
int MinimumRetentionDays
Gets the number of days to retain entries in the event log.
static bool Exists(string logName)
Determines whether the log exists on the local computer.
int Length
Gets or sets the length of the current T:System.Text.StringBuilder object.
static void DeleteEventSource(string source)
Removes the event source registration from the event log of the local computer.
void WriteEntry(string message, EventLogEntryType type)
Writes an error, warning, information, success audit, or failure audit entry with the given message t...
Defines the underlying structure of all code access permissions.
static void PrepareConstrainedRegions()
Designates a body of code as a constrained execution region (CER).
Provides the base implementation for the T:System.ComponentModel.IComponent interface and enables obj...
static void CreateEventSource(EventSourceCreationData sourceData)
Establishes a valid event source for writing localized event messages, using the specified configurat...
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
bool EnableRaisingEvents
Gets or sets a value indicating whether the T:System.Diagnostics.EventLog receives E:System....
Represents type declarations: class types, interface types, array types, value types,...
static GCHandle Alloc(object value)
Allocates a F:System.Runtime.InteropServices.GCHandleType.Normal handle for the specified object.
Provides a collection of methods for allocating unmanaged memory, copying unmanaged memory blocks,...
GCHandleType
Represents the types of handles the T:System.Runtime.InteropServices.GCHandle class can allocate.
string Log
Gets or sets the name of the log to read from or write to.
static string GetFullPath(string path)
Returns the absolute path for the specified path string.
Provides a way to access a managed object from unmanaged memory.
IntPtr AddrOfPinnedObject()
Retrieves the address of an object in a F:System.Runtime.InteropServices.GCHandleType....
long MaximumKilobytes
Gets or sets the maximum event log size in kilobytes.
Defines size and enumerators for a collection of T:System.Diagnostics.EventLogEntry instances.
virtual void CopyTo(Array array)
Copies the entire T:System.Collections.ArrayList to a compatible one-dimensional T:System....
static void Delete(string logName, string machineName)
Removes an event log from the specified computer.
string LogName
Gets or sets the name of the event log to which the source writes entries.
EventLog(string logName, string machineName, string source)
Initializes a new instance of the T:System.Diagnostics.EventLog class. Associates the instance with a...
static bool Exists(string logName, string machineName)
Determines whether the log exists on the specified computer.
virtual void Close()
Releases all resources held by the current T:System.Threading.WaitHandle.
static void WriteEntry(string source, string message)
Writes an information type entry with the given message text to the event log, using the specified re...
Represents a mutable string of characters. This class cannot be inherited.To browse the ....
virtual int Add(object value)
Adds an object to the end of the T:System.Collections.ArrayList.
static void RevertAssert()
Causes any previous M:System.Security.CodeAccessPermission.Assert for the current frame to be removed...
virtual object GetService(Type service)
Returns an object that represents a service provided by the T:System.ComponentModel....
Represents information about an operating system, such as the version and platform identifier....
static void CreateEventSource(string source, string logName)
Establishes the specified source name as a valid event source for writing entries to a log on the loc...
void BeginInit()
Begins the initialization of an T:System.Diagnostics.EventLog used on a form or used by another compo...
The exception that is thrown when one of the arguments provided to a method is not valid.
void Demand()
Forces a T:System.Security.SecurityException at run time if all callers higher in the call stack have...
Provides interaction with Windows event logs.
void Free()
Releases a T:System.Runtime.InteropServices.GCHandle.
static void Copy(Array sourceArray, Array destinationArray, int length)
Copies a range of elements from an T:System.Array starting at the first element and pastes them into ...
static bool CheckMachineName(string value)
Checks the syntax of the machine name to confirm that it does not contain "\".
UnicodeCategory
Defines the Unicode category of a character.
int Capacity
Gets or sets the maximum number of characters that can be contained in the memory allocated by the cu...
PermissionState
Specifies whether a permission should have all or no access to resources at creation.
DesignerSerializationVisibility
Specifies the visibility a property has to the design-time serializer.
static void DeleteEventSource(string source, string machineName)
Removes the application's event source registration from the specified computer.
Controls code access permissions for event logging.
EventLogEntryCollection Entries
Gets the contents of the event log.
OverflowAction
Specifies how to handle entries in an event log that has reached its maximum file size.
The exception that is thrown when a method call is invalid for the object's current state.
Provides static methods for the creation, copying, deletion, moving, and opening of a single file,...
Controls access to system and user environment variables. This class cannot be inherited.
static void CreateEventSource(string source, string logName, string machineName)
Establishes the specified source name as a valid event source for writing entries to a log on the spe...
void Assert()
Declares that the calling code can access the resource protected by a permission demand through the c...
static bool SourceExists(string source, string machineName)
Determines whether an event source is registered on a specified computer.
static void Delete(string path)
Deletes the specified file.
void Assert()
Declares that the calling code can access the resource protected by a permission demand through the c...
Provides information about a specific culture (called a locale for unmanaged code development)....
static int GetLastWin32Error()
Returns the error code returned by the last unmanaged function that was called using platform invoke ...
SecurityPermissionFlag
Specifies access flags for the security permission object.
void WriteEntry(string message, EventLogEntryType type, int eventID)
Writes an entry with the given message text and application-defined event identifier to the event log...
Specifies that this object supports a simple, transacted notification for batch initialization.
void RegisterDisplayName(string resourceFile, long resourceId)
Specifies the localized name of the event log, which is displayed in the server Event Viewer.
static EventLog [] GetEventLogs()
Searches for all event logs on the local computer and creates an array of T:System....
The exception that is thrown when a security error is detected.
Provides a unified way of converting types of values to other types, as well as for accessing standar...
static void WriteEntry(string source, string message, EventLogEntryType type, int eventID, short category, byte[] rawData)
Writes an entry with the given message text, application-defined event identifier,...
Performs operations on T:System.String instances that contain file or directory path information....
Provides methods to verify the machine name and path conform to a specific syntax....
void ModifyOverflowPolicy(OverflowAction action, int retentionDays)
Changes the configured behavior for writing new entries when the event log reaches its maximum file s...
static void Delete(string logName)
Removes an event log from the local computer.
Provides a set of static methods and properties that provide support for compilers....
Implements the T:System.Collections.IList interface using an array whose size is dynamically increase...
void WriteEvent(EventInstance instance, params object[] values)
Writes a localized entry to the event log.
delegate void EntryWrittenEventHandler(object sender, EntryWrittenEventArgs e)
Represents the method that will handle the E:System.Diagnostics.EventLog.EntryWritten event of an T:S...