JayceOoi.com

- Technology, mobile, photography, gaming, programming, anything -

Do you know to generate error information to Windows Event Log? Most of the Windows application will output error information to Windows Event Logs if there are issues in that application. How do we do that in C#?

We need to use System.Diagnostics namespace.

Codes to generate information to output to Windows Event Logs

EventLog myLog = new EventLog();
myLog.Source = “YourApplication”;
myLog.WriteEntry(“Error Description”, EventLogEntryType.Error);

Enjoy coding… ;)

How to modify Windows System Registry Values with C#? As usual, you need to use Microsoft.Win32 Namespace ~ using Microsoft.Win32;. Let’s take Windows Application Event Logs values as an example. I want to change the MaxSize and Retention values in Application Event Log file by using C#.

Codes to change Windows System Registry values

RegistryKey TestEventLog = Registry.LocalMachine.OpenSubKey(“System\\CurrentControlSet\\Services\\EventLog\\Application”,true);
TestEventLog.SetValue(“MaxSize”, “102367232″, RegistryValueKind.DWord);
TestEventLog.SetValue(“Retention”, “0″, RegistryValueKind.DWord);

Above codes open Application event log and with write permission (,true). It changes both MaxSize and Retention values.
Just change the codes to suit your need. ;)




Featured ...

Patriot FUEL+ 6000 & 9000 mAh Mobile Rechargeable Battery Review
64GB SanDisk Extreme microSDXC UHS-I Card Review
64GB Samsung microSDXC Pro UHS-1 Card Review

Guide for ...

Samsung Galaxy Note 3
Google Nexus 7 (2013)
Samsung Galaxy S4
Google Nexus 4
Samsung Galaxy Note 2
Google Nexus 7
Samsung Galaxy S3
HTC One X
Amazon Kindle Fire
Samsung Galaxy S2
HTC HD2

Follow ...