This chapter presented the WebLogger project, a fun online filter that grabs data about users who access your websitewithout their knowledge, unless you tell them they're being logged.
To log accesses to a web resource, you don't have to change that web resource; you can use a filter in Java-enabled web servers. To create a filter, you have to create a Java class that implements the Filter interface, which includes the init, doFilter, and destroy methods. When the user accesses the resource you're filtering, the doFilter method gets control, gaining access to the request object sent to the resource and the response object the resource sends back to the browser.
WebLogger uses the request object to get its information about the user, reading the URL the user is accessing, the user's IP address, hostname, and browser type. If the user is logged in using HTTP authentication, WebLogger records the type of authentication used and records the username. It also logs the time of the user's access, as well as the time he spent accessing the web resource you're filtering.
You've got options when it comes to where you want the log text sent with WebLogger. If you use Tomcat, that text is stored in stdout.log by default. But as discussed in this chapter, you can specify the log file you want to use. As also covered, you can create your own files, writing to them as you please.
WebLogger is a powerful project that lets you keep track of who's been visiting your site and log that information. Not bad.