Logging custom details of business events for site analysis
From a business point of view, you might want to log custom details of business events.
About this task
Note: The procedures that are described in the following
topic and subtopics work only for standard (JSR 168 or JSR 286) portlets.
The
following are main components of the site analysis logging framework
for standard portlets:
- com.ibm.portal.portlet.service.siteanalyzer.PortletSiteAnalyzerLoggingServiceHome
- This portlet service exposes methods to obtain a logger instance that is specialized on the specified request type. This request type is either an ActionRequest, an EventRequest, a RenderRequest, or a ResourceRequest. Portlets obtain this portlet service through a JNDI lookup.
- com.ibm.portal.portlet.service.siteanalyzer.PortletSiteAnalyzerLogger
- Portlets can retrieve an instance of this logger from the PortletSiteAnalyzerLoggingServiceHome. It is valid for the request for which it was created, and it provides methods to query the logger state - enabled or disabled - and to create a site analysis log entry.
- com.ibm.portal.portlet.service.siteanalyzer.ParameterNamesProcessor
- Request parameter names, in particular render parameter names that are encoded into portal URLs, should be as short in length as possible. This recommendation does not leave much space for meaningful parameter names in site analysis log entries. The ParameterNamesProcessor interface allows portlet developers to provide the PortletSiteAnalyzerLogger with a callback for processing request parameter names. Implementations of this interface are called by the site analytics framework before assembling the query string section of the request URI that is written to the site analysis log file.
Procedure
Results
Understanding the site analysis log for standard portlets: The site analysis log entries that are written by the PortletSiteAnalyzerLogger have the same structure as log entries created by other types of site analyzer loggers that the portal provides. This particular logger also implements the industry standard NCSA Combined.
The following example shows how the URL-encoded representation of the custom business event is
written to the request URI section of a log record. Non-ASCII characters are first encoded
as sequences of 2 or 3 bytes, by using the UTF-8 algorithm, before they are encoded as
%HH escapes. The encoded business event precedes the query
fragment, which starts with a question mark. Furthermore, the name of the request parameter
ciwas replaced by
ParameterNamesProcessorSample and now displays in the query
fragment of the request URI section of the log record as
CurrentItem.
9.37.3.88 - jdoe [22/Nov/2008:22:11:27 +0100] "GET /Portlet/
5_8000CB1A00U6B02NVSPH1G20G1/SamplePortlet/A%20sample%20business%20event
?PortletPID=5_8000CB1A00U6B02NVSPH1G20G1&PortletMode=view&PortletState=normal
&RequestType=render&CurrentItem=9783000216008 HTTP/1.1" 200 -1
"http://myserver.company.com/Page/6_8000CB1A00UR402F0JC25U1O25/SamplePage"
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.18) Gecko/20081029
Firefox/2.0.0.18" "JSESSIONID=0000JwIm04xm7btVLwzCj9Qo-uj:-1"