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

Read Windows Security Log

By , 8 Jan 2010
 
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

EdgeCat
Founder EdgeCat Infosys
Sri Lanka Sri Lanka
Member
Organisation (No members)

http://edgecat.weebly.com

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130516.1 | Last Updated 9 Jan 2010
Article Copyright 2010 by EdgeCat
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid