473,395 Members | 1,412 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,395 software developers and data experts.

Parsing an Error Log

if some one knows,how to parse a error log files and send the parsed date,error pattern to the Database..plz let me know!!
Feb 26 '07 #1
6 2796
if some one knows,how to parse a error log files and send the parsed date,error pattern to the Database..plz let me know!!
How to parse depends on the format of your log file ...

Greetz, Doc
Feb 26 '07 #2
Natti
15
Heres a pseudocode


open inputFile for reading
open outputFile for writing
while (!EOF) {
look for regular expressions that you need in the inputFile
if pattern matches write line to the outputFile
}
close inputFile
close outputFile
Feb 26 '07 #3
hii, how to write the perl program to parse a error log file for the websphere Application server?
for eg: if this s a error log file
[2/3/07 1:55:48:027 EST] 0000000a SystemErr R at com.ibm.ws.runtime.WsServerImpl.bootServerContaine r(WsServerImpl.java:182)
[2/3/07 1:55:48:028 EST] 0000000a SystemErr R at com.ibm.ws.runtime.WsServerImpl.start(WsServerImpl .java:120)

how the above lines should be parsed with the date,error codes and the error patterns.
Feb 27 '07 #4
hii, i m new to perl.just now started learning,can u plz specify the regular expression for the files?
i have wrote to split the date,but apart from date some other number is shown...

$date = 16/Nov/2005:031415
$date =~ ([^:]*):.*
[^:]* will match 16/Nov/2005
it is not coming....
Feb 27 '07 #5
@ramyaamar

Just to give you an idea:
Expand|Select|Wrap|Line Numbers
  1. @lines = (
  2.   "[2/3/07 1:55:48:027 EST] 0000000a SystemErr R at com.ibm.ws.runtime.WsServerImpl.bootServerContaine r(WsServerImpl.java:182)",
  3.   "[2/3/07 1:55:48:028 EST] 0000000a SystemErr R at com.ibm.ws.runtime.WsServerImpl.start(WsServerImpl .java:120)",
  4. );
  5.  
  6. for ( @lines ) {
  7.   ($date, $time, $errNo, $errStr, $location) = $_ =~ m(^\[(\d+/\d+/\d+)\s+(.*)\]\s+([\da-z]+)\s+(.*)\s+at\s+(.*)$);
  8.  
  9.   printf("date: '$date', time: '$time', err no: '$errNo', err str: '$errStr', location: '$location'\n");
  10. }
You should study regular expressions.

Greetz, Doc
Feb 27 '07 #6
KevinADC
4,059 Expert 2GB
best to learn all the perl basics including regexp, which is perls ace-in-the-hole, if learning is your goal. But you can also use CPAN if learning perl is not your objective but instead you need to get an application up and running before knowing perl very much. There are many modules already written for common tasks and for not so common tasks:

http://search.cpan.org/~mhamilton/Lo.../Log/Common.pm
Feb 27 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
2
by: Cigdem | last post by:
Hello, I am trying to parse the XML files that the user selects(XML files are on anoher OS400 system called "wkdis3"). But i am permenantly getting that error: Directory0: \\wkdis3\ROOT\home...
16
by: Terry | last post by:
Hi, This is a newbie's question. I want to preload 4 images and only when all 4 images has been loaded into browser's cache, I want to start a slideshow() function. If images are not completed...
3
by: David Svoboda | last post by:
I have a server program that takes commands and acts on them. The server program can also take these commands from an input file or standard input (mainly for testing purposes). As such, I often...
0
by: palabat | last post by:
Hello. I'm getting this error , "XML error parsing SOAP payload : Empty Document" when I try to execute a NuSOAP client in consuming a .NET web service. The response from the web service server...
13
by: Chris Carlen | last post by:
Hi: Having completed enough serial driver code for a TMS320F2812 microcontroller to talk to a terminal, I am now trying different approaches to command interpretation. I have a very simple...
0
by: =?Utf-8?B?VWxmIFRob3JzZW4=?= | last post by:
I use Visual Studio 2005 for a C-project using an external compiler, and came up with the idea that error parsing would be neat, i.e. enabling the functionality available for a "normal" build...
3
by: GazK | last post by:
I have been using an xml parsing script to parse a number of rss feeds and return relevant results to a database. The script has worked well for a couple of years, despite having very crude...
2
by: Felipe De Bene | last post by:
I'm having problems parsing an HTML file with the following syntax : <TABLE cellspacing=0 cellpadding=0 ALIGN=CENTER BORDER=1 width='100%'> <TH BGCOLOR='#c0c0c0' Width='3%'>User ID</TH> <TH...
1
by: hd95 | last post by:
In a perfect world my xml feed source would produce perfect xml ..that is not the case I am parsing an XML feed that sometimes has ampersands and dashes in the content that messes up my parsing. ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...
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,...
0
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...
0
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...

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.