You're replying to a comment by JA.

January 22, 2010, 19:45

Hi,
I'm trying to extract stacktraces from log files, looking for the pattern "Exception". If a line contains "Exception", a stack trace will follow in multiple lines. If the next line begins with a timestamp entry in the format "[1/13/10 23:17:00:444 CST]", the stack trace has ended in the previous line. Additionally, I want to grab the nearest line containing a timestamp entry above the line containing the pattern "Exception". Sometimes it's on the same line and other times it's a few lines above it. How can I do write a sed command for this? Example:

[1/13/10 23:01:16:623 CST] 00000059 SystemOut     O 2010-01-13 23:01:16,623 [ORB.thread.pool : 0] INFO  
 - Exiting isAlertUpdateTimerRunning()
SystemOut     O 2010-01-13 23:01:16,623 [ORB.thread.pool : 0] INFO  com.dd.dddd.ddddddddr.ddddddr.dddddddddTriggerManager
org.hibernate.SessionException: Session is closed!
        at org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:72)
        at org.hibernate.impl.SessionImpl.reconnect(SessionImpl.java:407)
        at com.ibm.ws.Transaction.JTA.RegisteredSyncs.distributeAfter(RegisteredSyncs.java:424)
        at com.ibm.ws.Transaction.JTA.TransactionImpl.distributeAfter(TransactionImpl.java:3885)
        at com.ibm.ws.Transaction.JTA.TransactionImpl.postCompletion(TransactionImpl.java:3864)
        at com.ibm.ws.Transaction.JTA.TransactionImpl.commitXAResources(TransactionImpl.java:2521)
        at com.ibm.ws.Transaction.JTA.TransactionImpl.stage1CommitProcessing(TransactionImpl.java:1647)
        at com.ibm.ws.Transaction.JTA.TransactionImpl.processCommit(TransactionImpl.java:1607)
        at com.ibm.ws.Transaction.JTA.TransactionImpl.commit(TransactionImpl.java:1542)
        at com.ibm.ws.Transaction.JTA.TranManagerImpl.commit(TranManagerImpl.java:240)
        at com.ibm.ws.Transaction.JTA.TranManagerSet.commit(TranManagerSet.java:164)
        at com.ibm.ejs.csi.TranStrategy.commit(TranStrategy.java:756)
        at com.ibm.ejs.csi.TranStrategy.postInvoke(TranStrategy.java:181)
        at com.ibm.ejs.csi.TransactionControlImpl.postInvoke(TransactionControlImpl.java:581)
        at com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:3910)
        at com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:3732)
[1/13/10 23:01:16:725 CST] 0000006e SystemOut     O 2010-01-13 23:01:16,725 [MessageListenerThreadPool : 12] INFO  com.ddconnector.cccccc.ccccccSession - Th
read[MessageListenerThreadPool : 12,5,main]

Here, I want to grab the first line, followed by the stack trace line starting "org.hibernate.SessionException" all the way until the last line of the stack trace.
Thanks.

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "unix_95": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.