WebLog servlet 1.8

This is a Java servlet lets you analyze the log file for your web-server. You can use this servlet as a simple analytical tool for reviewing visitors for your site.

How to use it:

a) copy weblogPackage.jar into WEB-INF/lib

b) describe WebLog servlet in web.xml file. As an initial parameter for this servlet you must set a path to configuration file describes log file format. Usually it must be pretty standard (so called NCSA log format). Parameter name is config.
 


    <servlet>
    <servlet-name>WebLog</servlet-name>
    <servlet-class>com.jsos.weblog.WebLog</servlet-class>
    <init-param>
    <param-name>config</param-name>
    <param-value>path_to_your_configuration_file</param-value>
    </init-param>
    </servlet>

c) define a mapping:
 


    <servlet-mapping>
     <servlet-name>WebLog</servlet-name>
     <url-pattern>/servlet/WebLog</url-pattern>
    </servlet-mapping>

Now the usage is:
 


http://your_host/servlet/WebLog?data_file

E.g. for our development environment (Orion server) it looks so:
 


http://your_host/servlet/WebLog?../log/default-web-access.log

    Here data_file is a full path to the log file for your web server (or copy of that file you are going to analyze). See the manual for your web server for getting the location for log files.

Configuration file is a text file, each line has got a form:
parameter=value
Empty lines and any line starts with # or // are ignored. In the configuration file you can set:
a) what is a structure for the each record in the log file
b) field delimiter
c) date format

You must describe record's structure as a sequence of integer numbers. Each number from this sequence describes one semantic element from the following list:
 
Element Number
Remote IP 1
Remote host 2
User ident 3
Authenticated user name 4
offset from GMT 5
Date/time 6
Date 7
Time 8
Request 9
Status code 10
Number of bytes send 11
Referrer 12
User agent 13
Site type 14
IP address the request was received on 15
Host name for the request was received on 16
Document served 17
Query string 18
Cookie 19

E.g. the following typical line

205.242.228.7 - - [04/Jan/2000:00:06:47 -0800] "GET / HTTP/1.0" 200 3294 "http://javaboutique.internet.com/ChatServlet/" Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)"

can be described as:
1 3 4 6 9 10 11 12 13

this line contains:
remote IP,User ident, Authenticated user name,date/time,request,status,bytes send,referrer and user_agent

Notes:
1) you can use 0 for all elements must be skipped when recorded line will be parsed (not described or not used fields)
2) you can use space or comma as a delimiter when you describe this format.

Each line in the configuration file describes one of the above mentioned parameters. Description has got the following form:
name_of_parameter=value_of_parameter

# Record format
# See description above. E.g.:
format=0,1,3,4,6,9,0,10,11,13

# Field delimiter:
# 1- space (default value)
# 2- comma
# 3 - tabulation
# E.g.:
delimiter=1

# date format
# 1 - dd/mmm/yyyy or dd/mmm/yy  e.g. 31/Jan/2000 (default value)
# 2 - mm/dd/yyyy or mm/dd/yy  e.g. 01/31/2000
# 3 - dd/mm/yyyy or dd/mm/yy e.g.  31/01/2000
# E.g:
date=1
 

    For downloading:   weblogPackage.jar

    Sample of config file: weblog
 

  © Coldbeans Software     Comments?

See also JSOS - the largest collection of servlets and filters.

Also in JSOS: