Analyze Tomcat logs with GoAccess

GoAccess is an open source real-time web log analyzer and interactive viewer that runs in a terminal in *nix systems.

It also can generate nice looking HTML reports.

I use it to analyze Tomcat servers logs and it works great.

If you’re running Fedora or RHEL/CentOS with EPEL repository enabled  you can easily install it with a simple:

 yum install -y goaccess

Next step is configure Tomcat to generate a suitable log file. I typically use this configuration in my server.xml

Then you can ask goAccess to read the log.

If you are interested in live monitoring just have to use this command (changing, of course, the date part of the file name and possibly the full path of your tomcat log directory):

goaccess -f /var/log/tomcat/localhost_access.2016-05-12.log \
--log-format='%h %^[%d:%t %^] "%r" %s %b "%R" "%u"' \
--date-format='%d/%b/%Y' \

If you want to generate a fancy HTML report, just add the -a option and redirect the output to a convenient file:

goaccess -f /var/log/tomcat/localhost_access.2016-05-12.log \
--log-format='%h %^[%d:%t %^] "%r" %s %b "%R" "%u"' \
--date-format='%d/%b/%Y' \
--time-format='%H:%M:%S' \
-a > report.html

that’s it!

Here’s an example of a such generated report.

I suggest you to take a look at the man page and/or at the documentation for more options and features.

Leave a Reply

Your email address will not be published. Required fields are marked *

What is 13 + 11 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)