Content
[R2] Technical Service Logging (TSL)
Issue To find performance and throughput bottlenecks it is a good start to measure the time execution of methods and persist this information so it can be monitored over time.
Solution This kind of logging is addressed with Technical Service Logging (TSL). A particular log appender is used to capture the MEASURED
logs and forward to a dedicated logfile with the file extension .tslog
.
TSL can be turned on by setting the log level of the MEASURED
category to INFO
or higher. The logs must be send to a predefined appender with name TSL
:
<logger name="MEASURED" level="OFF">
<appender-ref ref="TSL"/>
</logger>
Like all other logs also the TSL is tenant-aware and a log file is written for each tenant. The log looks like:
spGZLZ COMMON-Service 2019-05-03 11:43:30.080 DEBUG [35m[63638/4] [0;39m [2m- [0;39m [SERVICE_LAYER_ACCESS ] : [S]>> Method call: execution(TransportUnitServiceImpl.create(..))
spGZLZ COMMON-Service 2019-05-03 11:43:45.098 DEBUG [35m[63638/1] [0;39m [2m- [0;39m [SERVICE_LAYER_ACCESS ] : [S]<< execution(TransportUnitServiceImpl.create(..)) took [16] (ms)
If you want to see the TSL on the console instead then just refer to STDOUT
instead of TSL
:
<logger name="MEASURED" level="INFO">
<appender-ref ref="TSL"/>
<appender-ref ref="STDOUT"/>
</logger>
[R1] Doing Tomcat URL Encoding right
Problem Incoming http requests with URL parameters or request body data aren’t encoded correctly - even the request is decoded right. For example a request parameter that is decoded to %E6%8C could be encoded to æŒ but not to the expected String.
Solution By default, Tomcat uses ISO-8859-1 character encoding. The HTTP Connector in Tomcat’s server configuration must be configured to set the URL encoding to UTF-8. Open the server’s server.xml, search for the http connector and add the attribute "URIEncoding" as follows:
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" URIEncoding="UTF-8"/>