-
-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathExamples.WriteEvents.cs
More file actions
50 lines (46 loc) · 1.65 KB
/
Copy pathExamples.WriteEvents.cs
File metadata and controls
50 lines (46 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System.Diagnostics;
namespace EventViewerX.Examples;
internal partial class Examples {
public static void WriteBasic() {
ClassicEventLogManager.Write(
new ClassicEventWriteRequest {
SourceName = "MySource",
LogName = "Application",
MachineName = "AD1",
Message = "This is a test message",
EntryType = EventLogEntryType.Information,
EventId = 101,
ReplacementStrings = new[] {
"Replacement string 1",
"Replacement string 2"
}
});
}
public static void RegisterAndWriteToCustomLog() {
ClassicEventLogManager.EnsureLog(
new ClassicEventLogConfiguration {
LogName = "MyCustomLog",
SourceName = "MyApplication"
});
ClassicEventLogManager.Write(
new ClassicEventWriteRequest {
SourceName = "MyApplication",
LogName = "MyCustomLog",
Message = "This is a test message",
EntryType = EventLogEntryType.Information,
EventId = 101
});
}
public static void WriteWithRawData() {
ClassicEventLogManager.Write(
new ClassicEventWriteRequest {
SourceName = "MyApplication",
LogName = "MyCustomLog",
Message = "Authentication started.",
EntryType = EventLogEntryType.Information,
Category = 2,
EventId = 1001,
RawData = new byte[] { 1, 2, 3, 4 }
});
}
}