Here, a simple solution of log analyzer which allows error searching; This tools gives the possibility to search specific error keywords and skip others:
01 | String logFileNameAndPath = baseDir+File.separator+ "server.log" ; |
04 | ArrayList<String> errorsKeyword = new ArrayList<String>(); |
05 | errorsKeyword.add( "ERROR [" ); |
08 | ArrayList<String> errorsToSkip = new ArrayList<String>(); |
09 | errorsToSkip.add( "ERROR [STDERR]" ); |
11 | LogAnalyzer.analyzeLog(logFileNameAndPath, errorsKeyword, errorsToSkip); |
Following, examples of searching report:
01 | ---------- [ Report ] for tomcathuo.log (size:109355312)------------- |
02 | Analysing started at Tue May 01 01:52:28 CEST 2012 and ended at Tue May 01 01:53:02 CEST 2012 |
03 | Execution time is (34179ms): 0 min, 34 sec, 34145 ms |
12 | 632 occurences of : ORA- |
13 | 16 occurences of : 11:00:32,886 ERROR [ |
14 | 5104 occurences of : ERROR [ |
17 | ---------- [ Report ] for server.log (size:1085981)------------- |
18 | Analysing started at Tue May 01 01:47:41 CEST 2012 and ended at Tue May 01 01:47:41 CEST 2012 |
19 | Execution time is (47ms): 0 min, 0 sec, 47 ms |
27 | 4 occurences of : ERROR [STDERR] |
28 | 6752 occurences of : [error] |
29 | 323 occurences of : error |
30 | 323 occurences of : Fatal error: |
31 | 5 occurences of : ERROR [ |
32 | 87 occurences of : error 5 |
33 | 77 occurences of : PHP Fatal error: Call to undefined method PDF |
36 | ---------- [ Report ] for access.log (size:47072233)------------- |
37 | Analysing started at Tue May 01 01:47:53 CEST 2012 and ended at Tue May 01 01:47:55 CEST 2012 |
38 | Execution time is (2624ms): 0 min, 2 sec, 2622 ms |
40 | - GET /home/mysql/css/phpmyadmin.css.php |
45 | 4 occurences of : ERROR [STDERR] |
46 | 2118 occurences of : GET /home/mysql/css/phpmyadmin.css.php |
47 | 6752 occurences of : [error] |
48 | 323 occurences of : error |
49 | 323 occurences of : Fatal error: |
50 | 5 occurences of : ERROR [ |
51 | 87 occurences of : error 5 |
52 | 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
Related