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:

01String logFileNameAndPath = baseDir+File.separator+"server.log";
02 
03// Errors keywords
04ArrayList<String> errorsKeyword = new ArrayList<String>();
05errorsKeyword.add("ERROR [");
06 
07// Errors to skip
08ArrayList<String> errorsToSkip = new ArrayList<String>();
09errorsToSkip.add("ERROR [STDERR]");
10 
11LogAnalyzer.analyzeLog(logFileNameAndPath, errorsKeyword, errorsToSkip);

Following, examples of searching report:

01---------- [ Report ] for tomcathuo.log (size:109355312)-------------
02Analysing started at Tue May 01 01:52:28 CEST 2012 and ended at Tue May 01 01:53:02 CEST 2012
03Execution time is (34179ms): 0 min, 34 sec, 34145 ms
04Error Keywords:
05- ERROR [
06- ORA-
07 
08Error to skip:
09- 11:00:32,886 ERROR [
10 
11Error count :
12632 occurences of : ORA-
1316 occurences of : 11:00:32,886 ERROR [
145104 occurences of : ERROR [
15 
16 
17---------- [ Report ] for server.log (size:1085981)-------------
18Analysing started at Tue May 01 01:47:41 CEST 2012 and ended at Tue May 01 01:47:41 CEST 2012
19Execution time is (47ms): 0 min, 0 sec, 47 ms
20Error Keywords:
21- ERROR [
22 
23Error to skip:
24- ERROR [STDERR]
25 
26Error count :
274 occurences of : ERROR [STDERR]
286752 occurences of : [error]
29323 occurences of :  error
30323 occurences of : Fatal error:
315 occurences of : ERROR [
3287 occurences of : error 5
3377 occurences of : PHP Fatal error:  Call to undefined method PDF
34 
35 
36---------- [ Report ] for access.log (size:47072233)-------------
37Analysing started at Tue May 01 01:47:53 CEST 2012 and ended at Tue May 01 01:47:55 CEST 2012
38Execution time is (2624ms): 0 min, 2 sec, 2622 ms
39Error Keywords:
40- GET /home/mysql/css/phpmyadmin.css.php
41 
42Error to skip:
43 
44Error count :
454 occurences of : ERROR [STDERR]
462118 occurences of : GET /home/mysql/css/phpmyadmin.css.php
476752 occurences of : [error]
48323 occurences of :  error
49323 occurences of : Fatal error:
505 occurences of : ERROR [
5187 occurences of : error 5
5277 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