You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by David Weinrich <dw...@home.com> on 2001/01/05 23:59:39 UTC

AccessLog Helper class

Howdy!
  In the process of learning how valves work, I decided to create a minimal
JDBCAccessLogValve. After finishing the first test version of this I noticed
that I had pretty much copied/cut and pasted/stolen much of the
functionality of the existing AccessLogValve into this new class, and
started thinking... To try and get around the duplication of effort ( and to
learn a bit more ) I created an AccessLogHelper class that handles the
details of creating the access log entries and lets the Valve worry about
what to do with those entries. In the case of the existing valve this is
simply writing it out to a file, for a SyslogAccessLogValve, this would be
sending off a syslog message, for the JDBCAccessLogValve, this would be
entering the individual components of the entry in the database.
  A quick summary of the AccessLogHelper. The client configures the helper
in one of two ways:
  1) Setting the log format string/pattern, the helper parses this string
( or preselected aliases like "common" etc... ) and creates the objects
internally to handle log entry generation.
  2) Adding a series of individual fields ( probably provided through
parameters passed to the client of the helper through server.xml ), with
associated local and foreign names for the field ( to allow for some level
of independence on the names used in the database ).

  After configuration, the client passes the request and response objects to
the helper and gets either:
  1) The log entry as a string.
or
  2) The log entry fields as a List of strings.

  Right now just the very basic functionality is present, the helper doesn't
parse the incoming log format string, it is hardcoded to generate common log
format entries for now. I figured it would be a good thing(tm) to get
feedback on how this is implemented and the need for this fairly early on. I
have included the AccessLogHelper.java file ( I put it in the
org.apache.catalina.util package ) and a test access log valve, named
TestAccessLogValve.java ( unimaginative I know ) that goes in the
org.apache.catalina.valves package. Thanks again for the good work, and any
advice or critiques or pointers to more information are more than welcome.

David Weinrich