/
Enable HTTP Access Logging

Enable HTTP Access Logging

To enable access logs for our current

DDF

 do the following:

 

  1. Update the file (org.ops4j.pax.web.cfg) located in etc/ by adding the following text to the bottom: 

    org.ops4j.pax.web.config.file=etc/jetty.xml 


    This tells pax-web to look at the external jetty.xml file when performing initial jetty configuration.

  2. Update the jetty.xml file located in etc/ adding the following xml:

        <Get name="handler">
            <Call name="addHandler">
              <Arg>
                <New class="org.eclipse.jetty.server.handler.RequestLogHandler">
                  <Set name="requestLog">
                    <New id="RequestLogImpl" class="org.eclipse.jetty.server.NCSARequestLog">
                      <Arg><SystemProperty name="jetty.logs" default="data/log/"/>/yyyy_mm_dd.request.log</Arg>
                      <Set name="retainDays">90</Set>
                      <Set name="append">true</Set>
                      <Set name="extended">false</Set>
                      <Set name="LogTimeZone">GMT</Set>
                    </New>
                  </Set>
                </New>
              </Arg>
            </Call>
          </Get>
  3. Change the location of the logs to the desired location, in settings above will default to data/log (same place where the log is located).

 

The log is using NCSA format (hence the class 'NCSARequestLog'). This is the most popular format for access logs and can be parsed by many web server analytics tools. Here is a sample output:

 

127.0.0.1 -  -  [14/Jan/2013:16:21:24 +0000] "GET /favicon.ico HTTP/1.1" 200 0 
127.0.0.1 -  -  [14/Jan/2013:16:21:33 +0000] "GET /services/ HTTP/1.1" 200 0 
127.0.0.1 -  -  [14/Jan/2013:16:21:33 +0000] "GET /services//?stylesheet=1 HTTP/1.1" 200 0 
127.0.0.1 -  -  [14/Jan/2013:16:21:33 +0000] "GET /favicon.ico HTTP/1.1" 200 0 

Additional information:

http://team.ops4j.org/wiki/display/paxweb/Advanced+Jetty+Configuration

http://wiki.eclipse.org/Jetty/Tutorial/RequestLog