Apache Style Logging for Tomcat

19 Aug 2008
Posted by cgp

A lot of shops use the apache webserver in front of their tomcat servers to serve up their webservers. They use them essentially as proxies so that when the container server is taken down, the system can display a maintenance message or redirect to a web server which is up.

But, if you have something else doing this job, and have chosen to run just tomcat, how can you recreate those really nice apache logs to run analysis software like awstats against?

Well, actually, it's incredibly simple, and a quick look at the default configuration provides pretty much everything a server needs:

Just remember that the logger has attributes/options not shown on the valve documentation (but referred to), to control naming of the file logs.

Gotchas

You can't specify an absolute path in the directory attribute, so to get to the root or another path, you're going to have to go: "../../../../" until you get there.

References

  • Valve Reference Documentation
  • File Logging (controls naming of access logs)