...
This detects when a request is coming from a browser and returns HTML with syntax highlighted XML/JSON instead of just the raw text. In other words, if a user uses a browser to request "http://localhost:8080/openmrs/ws/fhir/Person/d9648997-4e01-406e-b47b-c00cb9b143bb" by typing this address into their URL bar, they will get nice formatted HTML back with a human readable version of the content. This is helpful for testers.
LoggingInterceptor
This can be used to generate a new log line (via SLF4j) for each incoming request.
Example log line:
2015-08-09 17:29:45 INFO accesslog:103 - Source[127.0.0.1] Operation[read Person/d9648997-4e01-406e-b47b-c00cb9b143bb] UA[Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.134 Safari/537.36] Params[]
The following substitution variables are supported:
${id} | The resource ID associated with this request (or "" if none) |
${idOrResourceName} | The resource ID associated with this request, or the resource name if the request applies to a type but not an instance, or "" otherwise |
${operationName} | If the request is an extended operation (e.g. "$validate") this value will be the operation name, or "" otherwise |
${operationType} | A code indicating the operation type for this request, e.g. "read", "history-instance", "extended-operation-instance", etc.) |
${remoteAddr} | The originaring IP of the request |
${requestHeader.XXXX} | The value of the HTTP request header named XXXX. For example, a substitution variable named "${requestHeader.x-forwarded-for} will yield the value of the first header named "x-forwarded-for", or "" if none. |
${requestParameters} | The HTTP request parameters (or "") |
${responseEncodingNoDefault} | The encoding format requested by the client via the _format parameter or the Accept header. Value will be "json" or "xml", or "" if the client did not explicitly request a format |
${servletPath} | The part of thre requesting URL that corresponds to the particular Servlet being called (see HttpServletRequest.getServletPath() ) |
You have to edit FHIRRESTServer.java file in order to add/remove this variables.
For see these logs in the log file you will need to edit apache-tomcat-7.0.59/webapps/openmrs/WEB-INF/classes/log4j.xml file.
"<logger name="org.openmrs.module">
<level value="INFO" />
</logger>"
<appender name="file" class="org.apache.log4j.RollingFileAppender">
<param name="append" value="false" />
<param name="maxFileSize" value="10000KB" />
<param name="maxBackupIndex" value="5" />
<!-- For Tomcat -->
<param name="file" value="${catalina.home}/logs/openmrs.log" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />
</layout>
</appender>
Edit the below part as well.
<root>
<level value="INFO" />
<appender-ref ref="CONSOLE" />
<appender-ref ref="file" />
</root>