Simple profiling
As of version v1.1 jLo includes a simple profiling tool. You can use the TimeTracker to start and stop time measurements. Like the NDC this tool uses the ThreadLocal to attach the time measuring to the specific thread. In order to start the timing use
TimeTracker.start();
If you want to stop the timing use:
TimeTracker.stop();
If the TimeTracker is used then the DefaultFormatter will also write out the timing. Here is an example:
2005/07/20 23:35:37 - [ellapsed: 0ms] [INFO] [org.jzonic.core.cache.AbstractCache] get(1)
2005/07/20 23:35:37 - [ellapsed: 31ms] [INFO] [org.jzonic.core.ControllerServlet] ProcessItem type:5
2005/07/20 23:35:37 - [ellapsed: 31ms] [INFO] [org.jzonic.core.ControllerServlet] saving context
If you want to display the timing using the
DefinedFormatter then you can use the
${elapsed}
token. For example you can define the
DefinedFormatter like this:
<parameter name="format" value="${date} ${elapsed} [${target}] - ${shortclass} : ${message}"/>
and it will generate the following output:
2005/07/20 23:35:37 - [ellapsed: 31ms] [INFO] - [ControllerServlet] : my log message