The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
mask_pop_op() Stack underflow error ! arunkumar_mca High Level Programming 1 03-17-2008 02:38 PM
get stack trace from C program on Solaris 8 rydahl Filesystems, Disks and Memory 4 03-23-2007 09:53 AM
help required - stack trace ranj@chn UNIX for Advanced & Expert Users 9 09-26-2006 05:20 AM
printing a stack trace with backtrace dmirza High Level Programming 2 11-03-2005 11:27 AM
Core file without a readable stack trace ciregbu High Level Programming 0 10-02-2002 08:42 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-11-2006
Registered User
 

Join Date: Jan 2006
Posts: 2
Need to capture ERROR msg and stack trace

Hi all,

I was hoping someone can point me in the right direction. I’m trying to filter out errors from a web log- any lines with ERROR in it. I know I could simply use the grep command to do this. However, there are times when a stack trace follows the error line. I would like to capture these lines as well. Here is a snippet of the web log:


2006-01-07 18:39:18,212 host123 WARN com.host123 .elf.UserQuest - Quest/option {o.q.more.paper.osc#0} references unknown dependent {t.what.form.file.more.action} in application {src-code}. Please revise.
2006-01-07 18:39:18,212 host123 WARN com.host123 .elf.UserQuest - Quest/option {o.q.more.paper.osc#1} references unknown dependent {t.what.form.file.more.action} in application {src-code}. Please revise.
2006-01-07 18:40:34,281 cessor32 ERROR com.host123 .email.DirectMailer - Unable to connect to server {1.1.1.1}:
javax.mail.MessagingException: Could not connect to SMTP host: 1.1.1.1, port: 25, response: 451
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:996)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:197)
at javax.mail.Service.connect(Service.java:233)
at javax.mail.Service.connect(Service.java:134)
at com.host123.email.DirectMailer.deliverMessage(DirectMailer.java:191)
at com.host123.email.DirectMailer.send(DirectMailer.java:153)
at com.host123.webface.util.Notifications.sendEmailX(Notifications.java:126)
at com.host123.webface.util.Notifications.sendEmail(Notifications.java:91)
at com.host123.webface.util.Notifications.sendEmail(Notifications.java:145)
at com.host123.edp.webface.action.DocRecoveryActionProcessor.perform(DocRecoveryActionProcessor.java:81 )
2006-01-07 18:43:45,811 host123 WARN com.host123.webface.RequestProcessorImpl - beanId = 7061279 beanTag= Docket , bean is null or unaccessible
2006-01-07 18:43:46,029 host123 WARN com.host123.webface.RequestProcessorImpl - beanId = 7061279 beanTag= Docket , bean is null or unaccessible



I would like to capture only the following lines and redirect the output to a file:

2006-01-07 18:40:34,281 cessor32 ERROR com.host123 .email.DirectMailer - Unable to connect to server {1.1.1.1}:
javax.mail.MessagingException: Could not connect to SMTP host: 1.1.1.1, port: 25, response: 451
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:996)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:197)
at javax.mail.Service.connect(Service.java:233)
at javax.mail.Service.connect(Service.java:134)
at com.host123.email.DirectMailer.deliverMessage(DirectMailer.java:191)
at com.host123.email.DirectMailer.send(DirectMailer.java:153)
at com.host123.webface.util.Notifications.sendEmailX(Notifications.java:126)
at com.host123.webface.util.Notifications.sendEmail(Notifications.java:91)
at com.host123.webface.util.Notifications.sendEmail(Notifications.java:145)
at com.host123.edp.webface.action.DocRecoveryActionProcessor.perform(DocRecoveryActionProcessor.java:81 )


I was thinking of incorporating some conditional logic, where we filter out lines with ERROR and also any lines thereafter that start with a white space (the stack trace lines start with a tab). Couldn't figure out how to tie that in with grep.

Thanks in advance for any ideas.

gsw
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 01-11-2006
Registered User
 

Join Date: Dec 2005
Location: London
Posts: 222
will it help ?

egrep "ERROR|^[ ]*java|^[ ]*at" tracefile

Please note : there is one tab and one space within braces ( for both)
Reply With Quote
  #3 (permalink)  
Old 01-11-2006
Registered User
 

Join Date: Jan 2006
Posts: 2
Woohoo!! it works!!

Thanks Mahendramahendr, I've been scratching my head on this for sometime!
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 03:01 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0