Click here to Skip to main content
Click here to Skip to main content

Read Windows Security Log

, 8 Jan 2010
Rate this:
Please Sign up or sign in to vote.
This Tip will show how to read the Windows Event Log (Security Log) in your PC.You have to use these two libraries for collecting and access to Event Log.using System.Net;using System.Diagnostics;I wrote security Log reading code on button Click event. In below code, I read Windows...
This Tip will show how to read the Windows Event Log (Security Log) in your PC.
 
You have to use these two libraries for collecting and access to Event Log.
using System.Net;
using System.Diagnostics;
 
I wrote security Log reading code on button Click event. In below code, I read Windows Security log. OIRC-09 is my computer's name.You can change these things according to your's PC.
 
private void button1_Click(object sender, EventArgs e)
        {
            EventLog EventLog1 = new EventLog("Security", "OIRC-09");
       </code>   
          
            foreach (System.Diagnostics.EventLogEntry entry in EventLog1.Entries)
            {
                if (entry.Category == "Logon/Logoff")
               ListBox2.Items.Add(entry.Message+"\n");
            }
 
        }
 
Here I read all Logon/Logoff messages and display it in a listbox. You can change the category of the event log and read it according to your necessacity.
 
Goto Windows Eventlog and read it carefully. Then you can get a proper idea about it.Path is ControlPanel>AdministrativeTools>EventViewer.
 
Remember reading the event log is not a difficult task.
meet you soon with eventlog writing code.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Unikoon
Founder EdgeCat Infosys
Sri Lanka Sri Lanka
http://edgecat.weebly.com

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 9 Jan 2010
Article Copyright 2010 by Unikoon
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid