2012년 11월 19일 월요일

[TechNote] New: Customizable Access Log Format in WAS 8.0.0.2


New: Customizable Access Log Format in WAS 8.0.0.2


New: Customizable Access Log Format in WAS 8.0.0.2

kgibm | Jan 25 | Comments (0) | Visits (328)
In a previous post, I covered some of the ways to log per-HTTP response time information in WAS. Good news -- a new and more standard approach has been added in WAS 8.0.0.2 through PM46717. WAS has had NCSA logging -- which is most commonly know through the LogFormat that httpd/IHS uses by default in its access/error logs -- but the format in WAS was not customizable, and did not have response times. WAS 8.0.0.2 introduces a customizable format which includes %D: "The elapsed time of the request. Millisecond accuracy, microsecond precision."
To set this up, you'll need to make two changes and then restart the affected servers: 1) enable NCSA access logging on the desired HTTP channels, and 2) set a custom property with the format string.
Note: Whether or not you already have NCSA access logging enabled globally on the server, you must explicitly enable it on the HTTP channel to use the custom format:
  1. Application servers > $SERVER > Web container settings > Web container transport chains > $CHAIN (e.g. WCInboundDefault) > $HTTP_CHANNEL (e.g. HTTP inbound channel)
  2. Check "Enable logging"
  3. Expand "NCSA Access logging"
  4. Check "Use chain-specific logging"
  5. Check "Enable access logging"
  6. Set the "Access log file path." For example, ${SERVER_LOG_ROOT}/access.log
  7. Set the "Access log maximum size" and "Maximum number of historical files." This is up to you, but I generally recommend 100MB with 5 historical files.
  8. It doesn't matter what "NCSA access log format" is set to, you'll override it next.
  9. Click Apply
If you clicked Apply, you'll still be on the HTTP channel page. From here:
  1. Click "Custom properties"
  2. Click "New..."
  3. Key=accessLogFormat
  4. Value=[See PM46717]. I recommend %h %u %t "%r" %s %b %D "%{Referer}i" "%{User-agent}i" %{JSESSIONID}C
  5. Click OK, save, synchronize and restart.
$ cat /work/was8002/nd/profiles/AppSrv01/logs/server1/access.log
0:0:0:0:0:0:0:1 - [24/Jan/2012:14:44:39 -0800] "GET /swat/Sleep HTTP/1.1" 200 - 1057000
"http://localhost:9080/swat/" "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24)
Gecko/20111104 Red Hat/3.6.24-3.el6_1 Firefox/3.6.24"
JSESSIONID:0000RyQoctdHbRhCkEJo5WexIYZ:-1

PM46717: HTTP CHANNEL ACCESS LOG CAN NOT BE CUSTOMIZED

Problem conclusion

  • To customize HTTP NCSA access logging, utilize the new
    functionality of the HTTP channel custom property
    "accessLogFormat". It will now accept a space separated list
    of directives. Each individual directive can have quotes
    around it. Any directive, unless otherwise noted, will use the
    value of "-" if no value is found. The list of directives
    available:
    * %a
    ** Remote IP Address
    * %A
    ** Local IP Address
    * %b
    ** Response size in bytes excluding headers
    * %B
    ** Response size in bytes excluding headers
    ** Will print 0 instead of - if no value is found
    * %C
    ** %{CookieName}C
    ** Prints the request cookie within the brackets or if the
    brackets are missing print them all
    * %D
    ** The elapsed time of the request. Millisecond accuracy,
    microsecond precision
    * %h
    ** Remote Host
    * %i
    ** %{HeaderName}i
    ** HeaderName header value from the request
    * %m
    ** Request Method
    * %o
    ** %{HeaderName}o
    ** HeaderName header value from the response
    * %q
    ** Output the query string with any password escaped
    * %r
    ** First line of the request
    * %s
    ** Status code of the response
    * %t
    ** NCSA format of the start time of the request
    * %{t}W
    ** Prints the current time when the message to the access log
    is queued to be logged in our NCSA format
    * %u
    ** Remote user according to the WebSphere Specific $WSRU header
    * %U
    ** URL Path, not including the query string
    
    To enable this new functionality please add the
    "accessLogFormat" custom property to the HTTP Channel, the
    panel on the administrative console can be found here:
    
    Application Servers > {Server Name} > Web Container Transport
    Chains > {Chain Name} > {HTTP Channel Name} > Custom Properties
    
    Also, please ensure the "Use chain-specific logging" option is
    enabled on the HTTP Channel where the previously mentioned
    property is enabled.
    
    The fix for this APAR is currently targeted for inclusion in
    fix pack 8.0.0.2.  Please refer to the Recommended Updates
    page for delivery information:
    http://www.ibm.com/support/docview.wss?rs=180&uid=swg27004980

댓글 없음:

댓글 쓰기