我有一个日志文件为..
>java.lang.IllegalStateException: Unable to crypt bytes with cipher [javax.crypto.Cipher@61e02bf7].
>Caused by: javax.crypto.IllegalBlockSizeException: Input length must be multiple of 8 when decrypting with padded cipher
>org.apache.solr.client.solrj.SolrServerException: Error executing query
>org.apache.jasper.JasperException: javax.servlet.ServletException: >net.sourceforge.stripes.exception.StripesJspException: An exception was raised while invoking
>Caused by: javax.servlet.ServletException: net.sourceforge.stripes.exception.StripesJspException: An exception was raised while invoking a layout. The layout used w
>Caused by: org.apache.jasper.JasperException: java.util.ConcurrentModificationException
>java.lang.NumberFormatException: empty String
>com.hk.exception.DefaultWebException: Order Total cannot be lesser than 0
>java.lang.NumberFormatException: For input string: ".E0"
我只需要一个以“Exception:”结尾的单词,而不是单词重复的结果。 例如.. ..
IllegalStateException 1
IllegalBlockSizeException 1
SolrServerException 1
JasperException 2
ServletException 2
NumberFormatException 2
DefaultWebException 1
请帮忙......
答案 0 :(得分:2)
如果你发布的那段日志文件被放入一个名为log的文件中,那么试试这个:
egrep -o '\<\w+Exception\>' log | sort | uniq -c
哪会给你:
1 ConcurrentModificationException
1 DefaultWebException
1 IllegalBlockSizeException
1 IllegalStateException
2 JasperException
2 NumberFormatException
2 ServletException
1 SolrServerException
2 StripesJspException
答案 1 :(得分:0)
或者您只需使用
如果需要, grep "<your search key word>" <log-file-name>
将输出重定向到文件。
grep命令也有几个选项。
答案 2 :(得分:0)
awk '{ for(i=1;i<=NF;++i) if (match($i,"Exception")!=0) {arr[gensub(/.*\.([a-zA-Z]*Exception[a-zA-Z]*).*/,"\\1","", $i)]++;} } END { for(v in arr) {print v, arr[v];} }' log
这是它的工作原理:
>awk '{ for(i=1;i<=NF;++i) if (match($i,"Exception")!=0) {arr[gensub(/.*\.([a-zA-Z]*Exception[a-zA-Z]*).*/,"\\1","", $i)]++;} } END { for(v in arr) {print v, arr[v];} }' log
ServletException 2
JasperException 2
ConcurrentModificationException 1
DefaultWebException 1
NumberFormatException 2
StripesJspException 2
IllegalStateException 1
SolrServerException 1
IllegalBlockSizeException 1