Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > extracting event logs to a file

Reply
Thread Tools

extracting event logs to a file

 
 
Gnaneshwar Babu
Guest
Posts: n/a
 
      12-31-2003
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Logs button not opening Logs GUI Lester Lane Cisco 6 08-28-2009 10:02 AM
WinXP Home SP2 logs in then right away logs off Andrew Computer Support 15 10-19-2004 09:45 AM
Win XP SP2 Logs in then Logs out awallwork at sign gmail dot com Computer Support 2 10-16-2004 08:19 PM
Win XP SP2 Logs in then Logs out Andrew Computer Support 2 10-16-2004 04:27 PM
WinXP Home SP2 Logs on then Logs off awallwork at sign gmail dot com Computer Support 2 10-16-2004 02:28 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57