Enabling request Log in Embedded Jetty

You can enable NCSA logging in Jetty so that it starts logging every request that enters Jetty with request details like this. It can be very useful for debugging sometimes. 127.0.0.1 - - [11/Apr/2012:15:44:19 +0000] "GET /ManageContact/rest/contact HTTP/1.1" 200 471 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.152 Safari/535.19" 127.0.0.1 - - [11/Apr/2012:15:44:21 +0000] "GET /ManageContact/rest/contact HTTP/1.1" 200 471 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.152 Safari/535.19" 127.0.0.1 - - [11/Apr/2012:15:44:26 +0000] "GET /ManageContact/rest/contact HTTP/1.1" 200 276 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.152 Safari/535.19" You can use following plugin configuration to enable the NCSA logging

<plugin>
  <groupId>org.mortbay.jetty</groupId>
  <artifactId>jetty-maven-plugin</artifactId>
  <version>7.4.5.v20110725</version>
  <configuration>
    <scanIntervalSeconds>10</scanIntervalSeconds>
    <webAppConfig>
      <contextPath>/ManageContact</contextPath>
    </webAppConfig> <!-- <loginServices> <loginService implementation="org.eclipse.jetty.security.HashLoginService"> 
      <name>Test Realm</name> <config>${basedir}/src/etc/realm.properties</config> 
      </loginService> </loginServices> -->
    <connectors>
      <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
        <port>9000</port>
        <maxIdleTime>60000</maxIdleTime>
      </connector>
    </connectors>
 
    <requestLog implementation="org.eclipse.jetty.server.NCSARequestLog">
      <filename>target/yyyy_mm_dd.request.log</filename>
      <retainDays>90</retainDays>
      <append>true</append>
      <extended>true</extended>
      <logTimeZone>GMT</logTimeZone>
    </requestLog>
 
  </configuration>
</plugin>
After this start the Jetty server and when you hit the service you will notice that a .log file gets created in the target directory with one entry for every request.

3 comments:

srjwebsolutions said...

We are leading responsive website designing and development company in Noida.
We are offering mobile friendly responsive website designing, website development, e-commerce website, seo service and sem services in Noida.

Responsive Website Designing Company in Noida
Website Designing Company in Noida
SEO Services in Noida
SMO Services in Noida

EG MEDI said...

Egmedi.com is online medical store pharmacy in laxmi nagar Delhi. You can Order prescription/OTC medicines online. Cash on Delivery available. Free Home Delivery


Online Pharmacy in Delhi
Buy Online medicine in Delhi
Online Pharmacy in laxmi nagar
Buy Online medicine in laxmi nagar
Onine Medical Store in Delhi
Online Medical store in laxmi nagar
Online medicine store in delhi
online medicine store in laxmi nagar
Purchase Medicine Online
Online Pharmacy India
Online Medical Store

Vikas Chaudhary said...

Battery Mantra is Authorized exide car battery dealer in Noida and Greater Noida. We are providing our service in Indirapuram, Delhi, Ashok Nagar.

Exide Battery Dealer in Noida
Battery Dealer in Noida
Authorized Battery Dealer in Noida
Car Battery Dealer in Noida
Car Battery Dealer
Exide Battery Dealer