473,671 Members | 2,588 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 5438
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
4428
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
2066
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
4878
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
3438
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
7365
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
2470
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
14634
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
3451
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
4376
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
8485
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8930
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8828
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...
1
8605
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8677
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
7446
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...
0
5704
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4417
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2062
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.