JavaBlog.fr / Java.lu DEVELOPMENT,Java,Tools Tools/Java: LogAnalyzer

Tools/Java: LogAnalyzer

Here, a simple solution of log analyzer which allows error searching; This tools gives the possibility to search specific error keywords and skip others:

String logFileNameAndPath = baseDir+File.separator+"server.log";

// Errors keywords
ArrayList<String> errorsKeyword = new ArrayList<String>();
errorsKeyword.add("ERROR [");

// Errors to skip
ArrayList<String> errorsToSkip = new ArrayList<String>();
errorsToSkip.add("ERROR [STDERR]");

LogAnalyzer.analyzeLog(logFileNameAndPath, errorsKeyword, errorsToSkip);

Following, examples of searching report:


---------- [ Report ] for tomcathuo.log (size:109355312)------------- 
Analysing started at Tue May 01 01:52:28 CEST 2012 and ended at Tue May 01 01:53:02 CEST 2012
Execution time is (34179ms): 0 min, 34 sec, 34145 ms
Error Keywords:
- ERROR [
- ORA-

Error to skip:
- 11:00:32,886 ERROR [

Error count : 
632 occurences of : ORA-
16 occurences of : 11:00:32,886 ERROR [
5104 occurences of : ERROR [


---------- [ Report ] for server.log (size:1085981)------------- 
Analysing started at Tue May 01 01:47:41 CEST 2012 and ended at Tue May 01 01:47:41 CEST 2012
Execution time is (47ms): 0 min, 0 sec, 47 ms
Error Keywords:
- ERROR [

Error to skip:
- ERROR [STDERR]

Error count : 
4 occurences of : ERROR [STDERR]
6752 occurences of : [error] 
323 occurences of :  error 
323 occurences of : Fatal error:
5 occurences of : ERROR [
87 occurences of : error 5
77 occurences of : PHP Fatal error:  Call to undefined method PDF


---------- [ Report ] for access.log (size:47072233)------------- 
Analysing started at Tue May 01 01:47:53 CEST 2012 and ended at Tue May 01 01:47:55 CEST 2012
Execution time is (2624ms): 0 min, 2 sec, 2622 ms
Error Keywords:
- GET /home/mysql/css/phpmyadmin.css.php

Error to skip:

Error count : 
4 occurences of : ERROR [STDERR]
2118 occurences of : GET /home/mysql/css/phpmyadmin.css.php
6752 occurences of : [error] 
323 occurences of :  error 
323 occurences of : Fatal error:
5 occurences of : ERROR [
87 occurences of : error 5
77 occurences of : PHP Fatal error:  Call to undefined method PDF

Some figures of the above reports:
– 2 seconds for the analyze of file whose size is 47Mo
– 34 seconds for the analyze of file whose size is 110Mo
of course, these figures depend of number of errors sought/searched or errors to be skipped.

Download: LogAnalyzer.zip

Tags: , , ,

Leave a Reply

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.

Related Post