473,498 Members | 1,557 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

extracting event logs to a file

Hi

I am facing a problem with extracting event logs of win32 to a file.
Am using the following code to extract eventlogs to file

use Win32::EventLog;
$handle=Win32::EventLog->new("System", $ENV{ComputerName})
or die "Can't open Application EventLog\n";
$handle->GetNumber($recs)
or die "Can't get number of EventLog records\n";
$handle->GetOldest($base)
or die "Can't get number of oldest EventLog record\n";
while ($x < $recs) {
$handle->Read(EVENTLOG_FORWARDS_READ|EVENTLOG_SEEK_READ,
$base+$x,
$hashRef)
or die "Can't read EventLog entry #$x\n";
if ($hashRef->{Source} eq "EventLog") {
Win32::EventLog::GetMessageText($hashRef);
print "Entry $x: $hashRef->{Message}\n";
}
$x++;
}

from this program i used get a output as shown bellow
----------------------------------------------------------------
C:\babu>perl eventlogg.pl
Entry : The Event log service was stopped.

Entry 1: Microsoft (R) Windows 2000 (R) 5.0 2195 Service Pack 3
Uniprocessor Fre
e.

Entry 2: The Event log service was started.

Entry 3: The Event log service was stopped.

Entry 4: Microsoft (R) Windows 2000 (R) 5.0 2195 Service Pack 3
Uniprocessor Fre
e.

Entry 5: The Event log service was started.

Entry 6: The Event log service was stopped.

Entry 7: Microsoft (R) Windows 2000 (R) 5.0 2195 Service Pack 3
Uniprocessor Fre
e.

Entry 8: The Event log service was started.

Entry 21: The Event log service was stopped.

Entry 22: Microsoft (R) Windows 2000 (R) 5.0 2195 Service Pack 3
Uniprocessor Fr
ee.

Entry 23: The Event log service was started.

Entry 24: The Event log service was stopped.

Entry 25: Microsoft (R) Windows 2000 (R) 5.0 2195 Service Pack 3
Uniprocessor Fr
ee.
--------------------------------------------------------------------
but i need a output as shown bellow

----------------------------------------------------------------------
Type Date Time Source Category Event User Computer
Information 12/31/2003 11:15:38 AM Dnsapi None 11152 N/A BDCVF-6GZR
Information 12/31/2003 11:15:17 AM VMnetuserif None 4 N/A BDCVF-6GZR
Information 12/31/2003 11:15:17 AM VMnetuserif None 1 N/A BDCVF-6GZR
Information 12/31/2003 11:14:26 AM VMnetAdapter None 34 N/A BDCVF-6GZR
Information 12/31/2003 11:14:26 AM VMnetAdapter None 34 N/A BDCVF-6GZR
Information 12/31/2003 11:14:40 AM eventlog None 6005 N/A BDCVF-6GZR
Information 12/31/2003 11:14:40 AM eventlog None 6009 N/A BDCVF-6GZR
Information 12/31/2003 11:13:42 AM eventlog None 6006 N/A BDCVF-6GZR
Warning 12/30/2003 1:40:08 PM Dnsapi None 11150 N/A BDCVF-6GZR
Information 12/30/2003 1:40:08 PM Dnsapi None 11156 N/A BDCVF-6GZR
Warning 12/30/2003 1:28:51 PM Dnscache None 11050 N/A BDCVF-6GZR
Information 12/30/2003 1:22:52 PM Browser None 8033 N/A BDCVF-6GZR
Information 12/30/2003 1:20:49 PM Dnsapi None 11152 N/A BDCVF-6GZR
Information 12/30/2003 1:20:48 PM Dnsapi None 11152 N/A BDCVF-6GZR
Information 12/26/2003 8:50:04 PM Application
Popup None 26 N/A BDCVF-6GZR
Information 12/24/2003 6:26:53 PM W32Time None 593 N/A BDCVF-6GZR
Error 12/22/2003 11:46:41 AM VMnetDHCP None 2 N/A BDCVF-6GZR
Information 12/22/2003 11:43:51 AM Dnsapi None 11152 N/A BDCVF-6GZR
---------------------------------------------------------------------------
Please help me in getting this output....
Thanks in adavance.
Jul 19 '05 #1
0 2928

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

Similar topics

1
3722
by: David Bear | last post by:
I would like to develop some tools to better understand/analyze windows event logs. What I've done is export the event log as a delimited file, then try to use awk or python to parse the info....
0
1433
by: marfi95 | last post by:
I'm automating a piece of my app to allow my customers to send me a copy of their event logs (for diagnostics) on demand just through the click of a button. I know I can use the...
1
2782
by: Z3Stealth | last post by:
I am writing a function in C# that will export the Application and System event logs to a file for viewing on another PC. I am using the EventLog class, and am able to browse the events in the...
1
1949
by: marfi95 | last post by:
I'm automating a piece of my app to allow my customers to send me a copy of their event logs (for diagnostics) on demand just through the click of a button. I know I can use the...
6
5202
by: Rico | last post by:
Hello, I'm creating an audit table and associated triggers to be able to capture any updates and deletes from various tables in the database. I know how to capture the records that have been...
7
5769
by: =?Utf-8?B?U3RldmVU?= | last post by:
I have a small app which tries reading the system, application, and security event logs within Vista. Many of the event logs return with a generic sentance indicating that: "The description for...
6
4424
by: Werner | last post by:
Hi, I try to read (and extract) some "self extracting" zipefiles on a Windows system. The standard module zipefile seems not to be able to handle this. False Is there a wrapper or has...
2
1992
by: zenosan | last post by:
SunOS bsm1b 5.9 Generic_118558-09 sun4u sparc SUNW,Netra-440 This is perl, v5.6.1 built for sun4-solaris I have listed the platform/OS information for your reference. I need to extract...
1
1320
by: PRR | last post by:
I have a functions (rather events).. which write to event logs every 3 to 5 seconds..There are 5 to 10 functions which do this .. writing to event logs... i m aware of the fact that writing to event...
0
7126
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
7210
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...
1
6891
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...
0
7381
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...
1
4916
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...
0
4595
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...
0
3096
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...
0
1424
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 ...
1
659
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.