To enable http level request/response logs in Application Server (AS), we can use the Access_Log_Valve
which is provided in Tomcat 7.
To enable logging, you have to put the following XML xml element under the /Server/Service
/Engine/Host/
directory
element in the {WSO2AS_HOME}/
repositoryr
epository/conf/tomcat/catalina
-server.xml
file and and restart the AS server.
Code Block |
---|
<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"/> |
...
Code Block |
---|
<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 above will log Content-type
, Content-Length
, Date Date
and Server
headers of every response coming from AS, as follows:
...
Code Block |
---|
<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 will log the First 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 AS as follows. (For more information on all possible values that can be given in the pattern
parameter, go to http://tomcat.apache.org/tomcat-7.0-doc/config/valve.html#Access_Log_Valve)
...
Thereafter, when the POST request is sent together with the URL encoded values param1
=value1
and param2
=value2
:
Code Block |
---|
POST http://<IP>:<PORT>/example/servlets/servlet/RequestInfoExample |
...