How do I turn on simple IIS style request logging in Tomcat

How do you turn on simple (local) request logging in tomcat (similar to the logging provided by default in IIS)?

Best Answer

  • mtaylor
    Answer ✓
    If you want to log ALL requests, then putting the following in the context.xml file should do the trick.
    This should log all requests to: $catalina_home/logs/request_log.txt. If you want to log to a specific directory, you would add a directory=”xxx” attribute. More specific info can be found [here][1] [1]:
    http://tomcat.apache.org/tomcat-5.5-doc/config/valve.html

Answers

  • If you are working on Cobalt, all Java modules are configured with a Cobalt Infrastructure request logging filter, which outputs request/response information to a log file. You can configure this with your `localdevelopment_[moduleName]-logging.xml` file (this file is usually under the `resources` classpath folder). Add the following `Appender` to your local logging file:










    Then, Add the following line to the `AsyncFile` appender:
    This should output request logging files to the logging folder you selected using the `-DappLogDir` startup property. Note that I got this configuration from CMDB, as the logging config files which are deployed with the modules are stored in CMDB.
  • put the following into **server.xml** (under the *host* node):


    as you can see, we use the shorthand pattern pattern="**combined**" to appends the values of the **Referer** and **User-Agent**(like Chrome, FF, IE ) to our log.