How to Clear the Event Log
Hello everyone,
I Have A Windows System installed With 2 gb Ram , I want to know how to clear the event log, or Can we set it to 1 month. so that it Self- Clean itself After 1 month , Is there any Setting that will allow me do this or any Script File PLease Provide a Way to clear my event logs Thanks in Advance for your responses.
Re: How to Clear the Event Log
Clearing the event data for a specific member deletes all of the event data from the Application Center event database for the member. For that reason, you will be unable to view or generate a report for the cluster member from this data. You might want to archive the event data before clearing it.
To clear the event data from the event log for a specific member
- In the Application Center snap-in, expand the cluster node, and then expand the Members node.
- Right-click the member's Events node, and then on the pop-up menu, click Clear events.
Re: How to Clear the Event Log
To clear an event log's contents programmatically
- Create an instance of the EventLog component and set the necessary properties to configure it
- Use the Clear method to clear the contents of the appropriate event log.
Your code should look something like this:
- Visual Basic
EventLog1.Clear()
- C#
EventLog1.Clear();
- J#
EventLog1.Clear();
Re: How to Clear the Event Log
The following script clears the Security event log after backing it up to a folder mentioned in the script. To run the script, copy the following contents to Notepad, and save the file with .vbs extension. Double-click to run the file.
Quote:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate, (Backup, Security)}!\\" _
& strComputer & "\root\cimv2")
Set colLogFiles = objWMIService.ExecQuery _
("Select * from Win32_NTEventLogFile where LogFileName='Security'")
For Each objLogfile in colLogFiles
OutputFile = "C:\" & "Security "
OutputFile = OutputFile & Day(Now) & "-" & month(now) & "-" & year(now)
OutputFile = OutputFile & ".evt"
errBackupLog = objLogFile.BackupEventLog(OutputFile)
If errBackupLog = 0 Or errBackupLog = 183 Then
objLogFile.ClearEventLog()
Else
Wscript.Echo "The Security event log could not be backed up."
End If
Next