Showing posts with label utilities. Show all posts
Showing posts with label utilities. Show all posts

Monday, July 25, 2011

How to extract exception stack trace from javaEE application log file ?

I had the requirement to extract complete list of exception stack trace from java EE application log files for past 6 months and analyze the root cause for all exceptions.

I used the following sed commands to get the list which has all duplicate list of exceptions.

sed -ne '/ERROR/,/WebContainer :/p' *.log.2011* >/tmp/exception_list.txt
sed -i '/WARN/d' /tmp/exception_list.txt
sed -i '/INFO/d' /tmp/exception_list.txt
sed '/com.ibm.ws/d' -e '/org.apache/d' /tmp/exception_list.txt
sed -e '/com.ibm.ws/d' -e '/org.apache/d' /tmp/exception_list.txt


Remove duplicate exception block from the log.

1) Remove time/date information from log entry cut -f 2 -d']'
exception_list.txt
2)Remove additional spaces if any sed 's/ ERROR/ERROR/'
/tmp/exception_list.txt

uniq
command will not work unless is sorted (sort), so use below command to remove duplicates with out changing line order

awk ' !x[$0]++'
/tmp/exception_list.txt >/tmp/exception_list_final.txt


Enter your Comments