File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Need to parse and analyse tomcat logs Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Need to parse and analyse tomcat logs" Watch "Need to parse and analyse tomcat logs" New topic
Author

Need to parse and analyse tomcat logs

Viidhya Kishore
Ranch Hand

Joined: Jan 03, 2007
Posts: 99
Hello all,
I have been assinged a projetc where I am to parse and analyse tomcat logs archive of 6 months and search for occurence of a String pattern.

Can someone help me to take the initial steps?
I am looking for either an opensource code project for the same or some code examples.

Please help.

-Viidhya
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3268

Well if you're using Java it should be too difficult to read in each log file and search based on a String pattern/Regular Expression. Many might argue that a language like PERL would be more suited for the task though...

In Java you can easily use the File and related I/O APIs to read the file into a buffer and the look at the Pattern and String apis for the regular expression pattern matching.


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Viidhya Kishore
Ranch Hand

Joined: Jan 03, 2007
Posts: 99
Thanks Martijn.
Well Pseudo of what I am supposed to do is :
1. Open each zip folder in archive folder.
2. If there is a file starting with 'Flare', open the file.
3. Search for occurence of a String in the file, and if exists, write the entry to an Excel/Csv file.
4. Do the same for all the zips in the folder.

Is this possible to be done using Java?
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3268

Absolutely yes.

There are even many tutorials and resources here on Javaranch to help you get started, see Here to begin.
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 852
I would look into using splunk. In a nutshell it compresses logs and allows you to query them and run ad hoc reports against them. It is free for even a fair amount of logs. Their site has lots of videos showing how it works. I installed and had it analyzing my logs in about 10 minutes. It is a very cool tool!

Recently I saw another product I can't recall the name of that let us look at our logs for the past 4 years by hour that was quite interesting...


http://www.jamonapi.com/ - a fast, free open source performance tuning api.
JavaRanch Performance FAQ
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Need to parse and analyse tomcat logs
 
Similar Threads
need help!!
Tomcal logging behaviour in Tomcat 6.0
location of log file when using log4j
Compiler Error
Tomcat newbie