extraction of info/data from a logfile


Mar 1, 2005
Programming Experience
hi.. i'm a newbie here.. i'd like to know how to search and extract specific lines from a logfile. attached is an example from the logfile.

i want to search for "WARNING" or "CRITICAL" from the log file and display the next lines of it until it sees blank spaces after the time stamp.. like this:

11/27/04 19:40:21:ERROR#**** Error: marsprod@cvspwcora010n2:MARS:eek:bject_extent_growth:WARNING ERROR
11/27/04 19:40:21:AC2_PROD_8_REPORT.BIB_BCT_NGBI. object has grown from 1 to 2 extents
11/27/04 19:40:21:AC4_PROD_17_REPORT.F_PROD_RTE_OPER_MASTER_RS_E. object has shrunk from 13 to 12 extents
11/27/04 19:40:21:AC4_PROD_17_REPORT.F_2WKBCK_LOTHIST_E. object has shrunk from 11 to 10 extents
11/27/04 19:40:21:AC4_PROD_17_REPORT.FC3_2WKBCK_LOTHIST_E. object has shrunk from 11 to 10 extents
11/27/04 19:40:21:AC4_PROD_17_REPORT.FC3_SHIPOUT_PER_OPER. object has grown from 5 to 6 extents
11/27/04 19:40:21:AC2_PROD_8_REPORT.TEMP_F_PCR878_REV3_EOW_V. object has shrunk from 12 to 1 extents
11/27/04 19:40:21:AC2_PROD_8_REPORT.TEMP_F_PCR878_REPORT_EOW_V. object has shrunk from 9 to 1 extents
11/27/04 19:40:21:AC2_PROD_8_REPORT.F_IBTG_FPOSUM. object has shrunk from 4 to 3 extents
11/27/04 19:40:21:AC3_PROD_7_REPORT.FLOT_SNAPSHOT. object has shrunk from 9 to 8 extents
11/27/04 19:40:21:AC2_PROD_8.XIE2F_LOTPARAMHIST. object has grown from 6697 to 6698 extents
11/27/04 19:40:21:AC2_PROD_8.XIE3F_LOTTXNHIST. object has grown from 3887 to 3888 extents
11/27/04 19:40:21:AC4_PROD_17_REPORT.FC3_2WKBCK_LOTHIST_IDX. object has shrunk from 11 to 10 extents
11/27/04 19:40:21:

Oh btw, I want to format the extraction like this:

02/28/05 03:06:57:ERROR#**** Error: marsprod@cvspwcora010n2:MARS:eek:bject_extent_growth:WARNING ERROR

02/28/05 03:06:57 Warning Error object_extent_growth details

details is a hyperlink and displays the next lines of it..

please anyone help me.. i'm really stuck on this one


  • file.txt
    44.5 KB · Views: 26
You could use streamreader to read it line by line, and the use instr to search for "Warning Error". If it is found then split the line into an array seperating it by the :'s, then just rearange the parts of the array and put it back together.