Need
It may be useful to generate access logs for web services exposed by xDI.
The access logs format is typically including information such as client IP address, local time, request details, response status, bytes sent, referee header, user-agent, request length, request time, and request ID.
Solution
Enable and configure access logs via the engineParameters.xml file located in the Runtime installation folder, with the following entries:
<javaConfiguration>
<property name="server.tomcat.accesslog.enabled" value="true"/>
<property name="server.tomcat.basedir" value="tomcat"/>
</javaConfiguration>
This configuration enables the Tomcat Access Log Valve, which allows logging of HTTP access in a specified format. Once enabled, the default pattern and other attributes, such as the log name and location, can be customized according to requirements.
For further customization, refer to the official Tomcat documentation, detailing the Access Log Valve attributes.
In particular, you can define a pattern by adding a 'pattern' property with the desired format.
Here is an example pattern:
<property name="server.tomcat.accesslog.pattern" value="%h [%t] ""%r" %s %b "%{Referer}i" "%{User-Agent}i" %I %D %{X-Request-ID}i"/>
Here is what each specifier means in the context of the log pattern:
%h - Remote hostname (or IP address if enableLookups for the connector is false)
[%t] - Date and time, in Common Log Format
"%r" - First line of the request
%s - HTTP status code of the response
%b - Bytes sent, excluding HTTP headers, or '-' if zero
"%{Referer}i" - The Referer header of the request
"%{User-Agent}i" - The User-Agent header of the request
%I - Current request thread name (can be correlated with the server thread)
%D - Time taken to process the request, in milliseconds
%{X-Request-ID}i - The content of the X-Request-ID header from the request or '-'
After updating the engineParameters.xml file with the appropriate properties, make sure to restart the xDI Runtime to apply these changes.