Showing posts with label ncsa. Show all posts
Showing posts with label ncsa. Show all posts

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.

Enabling NCSA loggin

If you want to view all the Http requests that your application server is handling then you can enable the NCSA log. This might be useful in case of clustered environment to see which server is actually handling particular request or you might be interested in looking at who is accessing the server at what time, load on the server during particular time

You can enable the National Center for Supercomputing Application(NCSA) using WAS Admin Console. Follow these steps

  • Log into the WAs ADMIn console

  • Go to the Servers -> Application Server. Select the server where you want to turn the NCSA log on. On the server details page click on HTTP error and NCSA access logging



  • On the "HTTP error and NCSA access logging" page, check the Enable access logging and Enable Service at startup check boxes. ALso set the Error log level

  • Now go back to the Application server details page, and go to Web Container transportation chain -> WCInboundDefault ->HTTP Inbound channel. Check the Enable access and error logging check box

  • Save your changes and restart the application server.

  • Now when you access the Application server every request would be logged in http_access.log file in the log folder of your application server.



This is sample log in my http_access.log file on websphere portal server

192.168.163.129 - - [26/May/2009:17:49:20 -0700] "GET /wps/portal HTTP/1.1" 200 16671
192.168.163.129 - - [26/May/2009:17:49:46 -0700] "POST /wps/portal/!ut/p/c5/04_SB8K8xLLM9MSSzPy8xBz9CP0os3hnd0cPE3MfAwN3cyNTAyM_02AjX8cwAwNfQ_1wkA6zeAMcwNFA388jPzdVvyA7rxwAZPfmsg!!/dl3/d3/L0lDUWtpQ1NTUW9LVVFBISEvb0lvZ0FFQ1FRREdJUXBURE9DNEpuQSEhLzRDd2lSLXJmbTE2SWt5WGlnRUEhLzdfQ0dBSDQ3TDAwRzcyNTAyTjVTMk1BVjAwRTQvd3BzLnBvcnRsZXRzLmxvZ2lu/ HTTP/1.1" 302 5
192.168.163.129 - - [26/May/2009:17:49:54 -0700] "GET /wps/myportal/!ut/p/c5/0wcA1NLTeQ!!/ HTTP/1.1" 200 49479
192.168.163.129 - - [26/May/2009:17:49:59 -0700] "GET /searchfeed/myserver/scopes?locale=en&customLinks=true&timeStamp=1243385067143 HTTP/1.1" 200 925
192.168.163.129 - - [26/May/2009:18:37:28 -0700] "GET /wps/themes/html/Portal/colors/default/menu_selected_disabled.gif HTTP/1.1" 200 825
192.168.163.129 - - [26/May/2009:18:37:28 -0700] "GET /wps/themes/html/Portal/colors/default/menu_selected.gif HTTP/1.1" 200 57