473,948 Members | 20,465 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Read event log from end

Hi,

I'm trying to write small program that reads events from computer
and stores them in SQL database.

But I don't know hove to read logs for let's say last 24 hours,
one solution is to read all events in event log and then check time.

foreach(EventLo gEntry Entry in logSystem.Entri es) {
//
// check time
//
}

And if a have 100k entries, this can take time.
Can I read logs from last to first?

Mihalic Krunoslav

Nov 16 '05 #1
2 5452
To read from the end, just use a for loop and Entries.Count. Be careful
about reading all the entries in first It can be many megabytes of data. I
recommend reading them in one at a time and stopping when you get past 1 day
old, like this:

EventLog myLog = new EventLog("Syste m");

for(int x = myLog.Entries.C ount - 1; x >= 0; x--)

{

EventLogEntry entry = myLog.Entries[x];

if (entry.TimeGene rated < DateTime.Now.Ad dDays(-1))

{

break;

}
// save the item

this.MySaveToSq lMethod(entry.T imeGenerated, entry.Message);

}

HTH

Dale Preston

MCAD, MCDBA, MCSE

<kr*******@gmai l.com> wrote in message
news:11******** **************@ l41g2000cwc.goo glegroups.com.. .
Hi,

I'm trying to write small program that reads events from computer
and stores them in SQL database.

But I don't know hove to read logs for let's say last 24 hours,
one solution is to read all events in event log and then check time.

foreach(EventLo gEntry Entry in logSystem.Entri es) {
//
// check time
//
}

And if a have 100k entries, this can take time.
Can I read logs from last to first?

Mihalic Krunoslav

Nov 16 '05 #2
Thanks, this is just what I need!

Mihalic Krunoslav

Nov 16 '05 #3

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

Similar topics

4
4442
by: Mike Dole | last post by:
I'm working on a client - server application based on the 'How to Sockets Server and How to Sockets Client' code from the Visual Basic ..NET Resource Kit. Since I want to be able to send 'big strings' instead of 'one liners' I check the streams for terminators. I'm having problems with the connection, I've been looking and debugging for 2 weeks now (debugging with an emulator is terribly slow..) but I'm not getting it...
12
2090
by: francisds | last post by:
Hi, Can you guys see if there's a solution to this problem? I have a database from which I have to read each record and process that record. New records are being added all the time, so I need to go back and check for new records and process them. However:
18
4913
by: jas | last post by:
Hi, I would like to start a new process and be able to read/write from/to it. I have tried things like... import subprocess as sp p = sp.Popen("cmd.exe", stdout=sp.PIPE) p.stdin.write("hostname\n") however, it doesn't seem to work. I think the cmd.exe is catching it.
16
453
by: Adda | last post by:
If I cycle through the MdiChildActivate event of the parent form I can read text in a textbox on the child mdiform -- console.writeline(Me.ActiveMdiChild.Controls(1).Text) But if I have a sub in the Parent form and reference a child mdi form like this: Sub ReadText()
2
3452
by: nekiv90 | last post by:
Greetings, How can 'rows read' from a DB2 CALL statement incur so many reads? I would expect it to be zero. Could someone enlighten me on this? Thanks! Here is output from executing event monitor on STATEMENTS: 68) Statement Event ...
7
7419
by: sergio-p | last post by:
I had no luck in my google search for this answer. Does anyone know if it's possible to read the entries in the Windows Event Log of the server running my PHP page? I'm trying to create an itranet page that lists errors from the server event log.... I'd prefer a pure PHP solution, but I'd be happy to try other alternatives that involve call outs to non-PHP code. Thanks in advance. - Sergio
8
2483
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. Do I need to somehow use EventLogPermission? I can't find any examples of how to use it properly. Does someone know how to correctly read the system event log messages? -- ----------- Thanks, Steve
3
14646
by: Mike | last post by:
I know there are server tools out there for this but are admins won't run them on test servers. what I need is a way to read the event view --system for a particular event. I need this to run every 15 minutes and when this event is logged I need an email to be sent to myself and another developer. Is there a way to do this?
5
3479
by: =?Utf-8?B?bXBhaW5l?= | last post by:
Hello, I am completely lost as to why I can't update a DropDownList inside a DetailsView after I perform an insert into an object datasource. I tried to simply it down to the core demostration: default.aspx:
3
4388
by: cmdolcet69 | last post by:
Im trying to raed data over a com port. The data comes over the serial port as such reading CRLF reading CRLF and so on. The code below only sees the first reading CRLF and then only added that into the DSIDXPort arraylist and never adds readings 2 through 16..... How can I get it to read those?
0
9989
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11184
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10697
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9902
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8261
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6122
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6343
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4952
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4545
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.