com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_link3' is unknown.

Enabling HTTP-Level Request/Response Logs

HTTP-level request/response logs help monitor your application's usage activities, such as who is accessing it, how many hits it receives, what the errors are etc. This information is useful for troubleshooting. Because the runtime of WSO2 products is based on Apache Tomcat, you can use the Access_Log_Valve variable in Tomcat 7 as explained below to enable HTTP-level request/response logs in WSO2 products. 

  1. Edit the Access_Log_Valve  variable in in <PRODUCT_HOME>/repository/conf/tomcat/catalina-server.xml file as shown in the example below:

    <Valve className="org.apache.catalina.valves.AccessLogValve"
    directory="${carbon.home}/repository/logs"
    prefix="localhost_access_log_sample."
    suffix=".log"
    pattern="%{xxx}i %{xxx}o"
    resolveHosts="false"/>

     Note the following:

    • The pattern attribute defines the parts of the request/response that should be logged.
      • xxx stands for the header name you log
      • %{xxx}i  stands for the request headers
      • %{xxx}o stands  for the response headers

    See all possible values that can be given in the pattern attribute in http://tomcat.apache.org/tomcat-7.0-doc/config/valve.html#Access_Log_Valve.

  2. Restart the server. It creates a log file named localhost_access_log_sample.<DATE>.log inside <PRODUCT_HOME>/repository/logs where access logs will be recorded.

Given below are few sample configurations:

Example 1: Logging request headers

The configuration is as follows:

<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="${carbon.home}/repository/logs"
prefix="localhost_access_log_test."
suffix=".log"
pattern="%{Content-Type}i %{Accept}i %{Accept-Encoding}i"
resolveHosts="false"/>

This sample logs the  Content-type, Accept and Accept-encoding headers of every request coming to the server. For example, in the following example, we use RequestInfoExample to send the HTTP request:

GET http://<IP>:<PORT>/example/servlets/servlet/RequestInfoExample?abc=xyz

It records the following log entry in localhost_access_log_sample.{DATE}.log file.

text/plain; charset=utf-8        */*        gzip,deflate,sdch

Example 2: Logging response headers

The configuration is as follows:

<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="${carbon.home}/repository/logs"
prefix="localhost_access_log_test."
suffix=".log"
pattern="%{Content-Type}o %{Content-Length}o %{Date}o %{Server}o"
resolveHosts="false"/>

The a bove sample logs the  Content-type, Content-Length, Date  and Server headers of every response coming from the server as follows:

text/html;charset=ISO-8859-1       662       Tue, 09 Jul 2013 11:21:50 GMT        WSO2 Carbon

Example 3: Logging other variable values

The configuration is as follows:

<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="${carbon.home}/repository/logs"
prefix="localhost_access_log_test."
suffix=".log"
pattern="%r %q %h"
resolveHosts="false"/>

The above sample logs the first line of the request (method and request URI), query string (prepended with a '?', if it exists) and remote hostname (or IP) of every request coming to the server as follows:  

“GET /example/servlets/servlet/RequestInfoExample?abc=xyz HTTP/1.1”      ?abc=xyz     10.100.0.67

Example 4: Logging URL-encoded attributes

You cannot use AccessLogValve to log URL-encoded attributes. For this purpose, you can use the ExtendedAccessLogValve attribute. In this example, only two values (namely,  className  and pattern ) are modified from the previous configuration.

The configuration is as follows:

<Valve className="org.apache.catalina.valves.ExtendedAccessLogValve" 
directory="${carbon.home}/repository/logs"
prefix="localhost_access_log_extended."
suffix=".log"
pattern="x-P(param1) x-P(param2)"
resolveHosts="false"/>

Send a POST request with URL- encoded values such as  param1=value1  and  param2=value2 as follows:

POST http://<IP>:<PORT>/example/servlets/servlet/RequestInfoExample

The  above configuration logs the following:

'value1'     'value2'
com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links2' is unknown.