Ars Machina
Software development isn't just technique, it is an art too

Tapestry Access Logger

This package provides support for easy logging of user accesses (visits) in Tapestry 5 applications. It provides out-of-the-box logging using SFL4J and the standard output.

A logger is a class that implements AccessLogger. For each request that must be logged, Tapestry Access Logger invokes its void log(Access access) method. Access is a class provided by this package to represent one user access (visit).

Access properties:

url
Requested URL
contextPath
Requested context path (application)
page
Requested Tapestry 5 page
activationContext
Requested Tapestry 5 page activation context
referer
Value of the referer HTTP header (URL that linked to the requested page)
ip
Visitor's IP address
sessionId
jsessionid value
remoteHost
Visitor's host
userAgent
Value of the User-Agent HTTP header. It indicates the browser used by the visitor.
locale
Locale requested by the user agent
user
The User that made the request or null if the user was not logged. This class comes from the Generic Authentication package.

Tapestry Access Logger-Hibernate provides user access logging to almost any database using Hibernate.

Creating loggers

Loggers are added to the AccessLoggerHub service. This is done adding a method in your application's AppModule class. Example using the Slf4JAccessLogger:

public void contributeAccessLoggerHub(OrderedConfiguration<AccessLogger> configuration) {
	AccessLogger logger = new Slf4JAccessLogger();
	configuration.add("slf4j", logger);
}				

Configuration

By default, only page requests are logged. If you want to change this behaviour, create an AccessFilterRule. Its only method, Boolean accept(String path), must return true if the request to that path must be logged, false if the request must not be logged, and null to allow other rules to decide.

To add your custom filter rule, contribute it to the AccessFilter service in your application AppModule. Example using the URLEndingAccessFilterRule to log all requests to JAR files:

public void contributeAccessFilter(OrderedConfiguration<AccessFilterRule> rules) {
	AccessFilterRule rule = new URLEndingAccessFilterRule(".jar");
	rules.add("jar", rule);
}