Open a PowerShell terminal.
The New-EventLog command creates an Event Log MyLog and registers an Event Source "MyLogSource" to it:
> New-EventLog -source MyLogSource -LogName MyLog
Using the Event Viewer, you can see the Event Log is generated under the category "Applications and Services Logs".
You may use the Write-Event command to write an event to the Event Log:
> Write-EventLog -source MyLogSource -LogName MyLog -EventId 1 -Message "Hello World"
In C#, you can write an event to the above Event Log like this:
EventLog.WriteEntry("MyLogSource", "Hello World", EventLogEntryType.Information);
If you decide to delete the Event Log together with all the events in it, you can run command Remove-EventLog:
> Remove-EventLog -LogName "MyLog"
Friday, October 25, 2019
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment