473,387 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Read archived eventlog in C#

Hi,

How to read archived system eventlog file (*.evt) in C# ?
Any code samples ?

-Mike
Nov 15 '05 #1
9 8060
Mike,

Unfortunately, I don't believe that there is. If anything, you will
have to call the appropriate API functions through the P/Invoke layer.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mike" <Mi**@nospam.com> wrote in message
news:0b****************************@phx.gbl...
Hi,

How to read archived system eventlog file (*.evt) in C# ?
Any code samples ?

-Mike

Nov 15 '05 #2
Don't archive using the eventlog format, use CSV or TAB delimited format
instead.
Parsing a CSV TAB delimited file should be trivial using the
System.IO.StreamReader class.

Willy.

"Mike" <Mi**@nospam.com> wrote in message
news:0b****************************@phx.gbl...
Hi,

How to read archived system eventlog file (*.evt) in C# ?
Any code samples ?

-Mike

Nov 15 '05 #3

Hi Mike

Thanks for posting in this group.
Why not you read the eventlog directly using System.Diagnostics.EventLog
class?
If you want to archive the eventlog, I think Willy's suggestion may meet
your need.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #4
I wanted to filter-out events ( based on particular event-
id, source, message, etc) from the archived eventlog
( .evt or .csv format or .txt format) ;

C# Samples?
Are there any helper classes in C# to achieve the same?

-Mike
-----Original Message-----

Hi Mike

Thanks for posting in this group.
Why not you read the eventlog directly using System.Diagnostics.EventLogclass?
If you want to archive the eventlog, I think Willy's suggestion may meetyour need.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
.

Nov 15 '05 #5
Hi Mike,

The following steps are for your reference:

1. Export the event log to a CSV file. Create a new folder and put the CSV
file in that folder.
2. Create a ODBC Data Source that uses "Microsoft Text Driver". Change the
"Directory" for the database to the directory that holds the CSV file.
3. In VS.Net, use OdbcDataAdapter and OdbcConnection to connect to the ODBC
Data Source created in step 2.
4. Use the OdbcDataAdapter to fill the DataSet.
5. Use a DataView to do the filtering.

Most of the steps above can be done without doing any coding work. I hope
this helps.

Regards,

Felix Wang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #6
No.

I want to do it programatically using C# like filter events in %systemroot%\system32\eventquery.vbs .
any C# sample you could point-out
----- \"Jeffrey Tan[MSFT]\" wrote: ----
Hi Mike

Does my colleague's suggestion resolve your problem
If you still have anything unclear, please feel free to tell me

Best regards
Jeffrey Ta
Microsoft Online Partner Suppor
Get Secure! - www.microsoft.com/securit
This posting is provided "as is" with no warranties and confers no rights
Nov 15 '05 #7

Hi Mike,

Thanks for your feedback.
I will do some research on it. I will reply to you ASAP.
Thanks for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #8
This script doesn't read archived eventlogs, it's reads/filters regular
eventlogs based on input criteria.

Willy.

"Mike" <an*******@discussions.microsoft.com> wrote in message
news:53**********************************@microsof t.com...
No.

I want to do it programatically using C# like filter events in
%systemroot%\system32\eventquery.vbs .
any C# sample you could point-out ?

----- \"Jeffrey Tan[MSFT]\" wrote: -----
Hi Mike,

Does my colleague's suggestion resolve your problem?
If you still have anything unclear, please feel free to tell me.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no
rights.

Nov 15 '05 #9

Hi Mike,

I have writen a sample project to read the CSV file for you.

You can try the following Solution to see if it helps resolve your issue:

1). Save your eventlog into a directory: D:\test\test.csv
2). Create a system ODBC DNS for your test.csv
3). Use ADO.net ODBC provider to read this file and bind it to the WinForm
datagrid control to display
private void lightButton1_Click(object sender, System.EventArgs e)
{
OdbcDataAdapter oda = new OdbcDataAdapter("SELECT * FROM test.csv",
this.odbcConnection1);
DataSet ds = new DataSet();
oda.Fill(ds);
this.dataGrid1.DataSource = ds.Tables[0];
}

============================================
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Joe | last post by:
I am trying to read the EventLog of different servers on the network. If I run the script in a command line, it works well. But when I try to put the script into the Web server (IIS in Windows...
0
by: Sandrine Gangnebien | last post by:
Hi all, I use replication between two 7.2 db2 udb. The kind of replication is 'update anywhere' and capture is stopping about every day beacause it is missing a log that is already archived....
1
by: martin | last post by:
Hi, I'm having some problems with the System.Diagnostics.EventLog class in .NET 2.0 I need to recreate an event message source inside a new log but the messages keeps ending up in the old...
4
by: Seok Bee | last post by:
Dear Experts, I have created a script to extract the Event Logs from the system into an excel sheet. The logs are separated into 2 worksheets (Application Log and System Log). After this excel...
4
by: PeterW | last post by:
I have a Windows service that needs to get some values from a config file. I place the config file for the service in the System32 directory. I do not get the values using the usual...
1
by: Pucca | last post by:
I'm using vs2005, .net 2.0 on Windows 2000 server. When I double click on an entry of the "Security" log in the system's "Event Viewer", a Property window pops up. In this window, there is a...
8
by: =?Utf-8?B?U3RldmVU?= | last post by:
Under Vista, my program, when reading the system event log, will not show the message saying I don't have the right permission. All I wisht to do is read the event log and show the error messages....
2
by: d33a | last post by:
Hello, I have a small question. I am using asp .net 2.0 and i am trying to read from the event viewer and display in a console the users that have logged on the computer, first and last...
3
by: JulesII | last post by:
Hi, I have a database which is able to show projects which are current and those which are archived. The users need to be able to search the archived data but are not allowed to edit it in anyway. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.