How to write C#.NET code for Log Size groupbox(in Properties window,Application eventlog,Eventviewer in WIndows XP OS) in EventViewer - Eventlog Properties.
Please provide me the code for the same.
How to write C#.NET code for Log Size groupbox(in Properties window,Application eventlog,Eventviewer in WIndows XP OS) in EventViewer - Eventlog Properties.
Please provide me the code for the same.
I think what sukumar is asking is how can he programatically change the size of an event log in C#?
// Get the Event Log
this.eventLog = new EventLog();
this.eventLog.Source = "Your.Log.Source";
// Configure the Event Log
// Set the log size
this.eventLog.MaximumKilobytes = 5120;
// Ower-write old records when log becomes full
this.eventLog.ModifyOverflowPolicy(OverflowAction.OverwriteAsNeeded, 0);
// Add the trace listner
Trace.Listeners.Add(new EventLogTraceListener(this.eventLog));
If you righ-click on an event log (eg the Application Log), and select properties. You will see there is a log size that you can set.
The problem is say you have a custom log that you are writing to. The overflow action is set to DoNotOverwrite
(by default), if you don't change it to OverwriteAsNeeded
, you will throw an exception when the log becomes full. System logs seem to have OverwriteOlder
as a default.
Increasing the log size just gives you a bigger history...