The Oracle Commerce Platform includes a formatting file logger component that can be set to log page requests from users, /atg/dynamo/service/logging/RequestLogger
. The RequestLogger
logs properties of the request and response objects for each user request, which it obtains from the ATGServlet
. To use the RequestLogger
, set the dataListeners
property of /atg/dynamo/servlet/pipeline/DynamoServlet
as follows:
dataListeners=/atg/dynamo/service/logging/RequestLogger
You can set the dataListeners
property using the Event tab in the Component Editor:
Select the
data
event set.In the Registered Event Listeners column, click ....
Click Insert Before or Insert After.
Select
/atg/dynamo/service/logging/RequestLogger
as a registered event listener.
The RequestLogger
has the following properties file:
$class=atg.service.datacollection.FormattingFileLogger # directory and file name logFileDir=logs logFileName=request.log formatFields=request.remoteAddr,' - - [',currentDate:d/MMM/yyyy:H:mm:ss,'] "',request.method,' ',request.requestURI,' ',request.protocol,'" ',response.status,' -' # the default field delimiter is a tab char ('\t') # in this example we set it to null as our formatFields # above include custom field delimiters fieldDelimiter=
The $class
line loads the FormattingFileLogger
class, which formats data items and logs them to a file. The logFileDir
and logFileName
properties control the file you log to.
The key property to look at here is formatFields
. This is an ordered list of the properties to log. In this example, the RequestLogger
is expecting data items that have properties named request.remoteAddr
, request.method
, request.requestURI
, request.protocol
, and response.status.
The RequestLogger
gets this data from the request and response objects. By default, fields are delimited by tabs and terminated by newlines. However, the formatFields
property in this example provides custom field delimiters. One line in the log is written for each data item that the logger receives. To log just the requestURI
, change the formatFields
property to:
formatFields=request.requestURI
This writes to the logs/request.log
file, entering the request.requestURI
of each data item followed by a newline.