Index | Next | Prev

14. Introduction to listeners

> A listener is a component that shows the results of the samples. The results can be shown in a tree, tables, graphs or simply written to a log file. To view the contents of a response from any given sampler, add either of the Listeners "View Results Tree" or "View Results in table" to a test plan. To view the response time graphically, add graph results, spline results or distribution graph. The listeners section of the components page has full descriptions of all the listeners.

> Different listeners display the response information in different ways. However, they all write the same raw data to the output file - if one is specified.

> The "Configure" button can be used to specify which fields to write to the file, and whether to write it as CSV or XML. CSV files are much smaller than XML files, so use CSV if you are generating lots of samples.

> If you only wish to record certain samples, add the Listener as a child of the sampler. Or you can use a Simple Controller to group a set of samplers, and add the Listener to that. The same filename can be used by multiple samplers - but make sure they all use the same configuration!

14.1 Screen captures

> JMeter is capable of saving any listener as a PNG file. To do so, select the listener in the left panel. Click edit -> Save As Image. A file dialog will appear. Enter the desired name and save the listener.

> Figure 1 - Edit -> Save As Image

14.2 non-GUI (batch) test runs

> When running in non-GUI mode, the -l flag can be used to create a top-level listener for the test run. This is in addition to any Listeners defined in the test plan. The configuration of this listener is controlled by entries in the file jmeter.properties.

> This feature can be used to specify a different data log file for each test run, for example: `jmeter -n -t testplan.jmx -l testplan_01.jtl jmeter -n -t testplan.jmx -l testplan_02.jtl`

> However, note that jmeter logging messages are written to jmeter.log by default. This file is recreated each time, so if you want to keep the log files for each run, you will need to rename it after the run has finished. Or you can use the environment variable JVM_ARGS to pass in the option -Dlog_file=filename. This will define the Java system property, which will be used as the default JMeter property if not overridden in jmeter.properties If you are using an OS such as VMS just use a logical name for the log file in jmeter.properties and define the logical before starting JMeter.

14.3 Resource usage

> Listeners can be quite resource intensive so use as few as possible. For minimum resource usage, remove all listeners, and run the test in non-GUI mode with the -l flag to define a single listener. The result log file can be read back into a Listener after a test has completed.

14.4 CSV Log format

> The CSV log format depends on which data items are selected in the configuration. Only the specified data items are recorded in the file. The order of appearance of columns is fixed, and is as follows:

> - timeStamp - in milliseconds since 1/1/1970
> - elapsed - in milliseconds
> - label - sampler label
> - responseCode - e.g. 200, 404
> - responseMessage - e.g. OK
> - threadName
> - dataType - e.g. text
> - success - true or false
> - failureMessage - if any
> - bytes - number of bytes in the sample
> - URL

> The format of the XML files is as follows:

14.5 XML Log format 2.0

> The format of the original XML (2.0) is as follows (line breaks will be different):

>     <?xml version="1.0" encoding="UTF-8"?>
>     <testResults version="1.2">
>     <sampleResult timeStamp="1144365463297" dataType="text" threadName="Listen 1-1" label="HTTP Request" time="1502" responseMessage="OK" responseCode="200" success="true">
>      <sampleResult timeStamp="1144365464238" dataType="text" threadName="Listen 1-1" label="http://www.apache.org/style/style.css" time="171" responseMessage="OK" responseCode="200" success="true">
>      <property xml:space="preserve" name="samplerData">
>      GET http://www.apache.org/style/style.css
>      </property>
>      <binary>
>      body, td, th {
>         font-size: 95%;
>         font-family: Arial, Geneva, Helvetica, sans-serif;
>         color: black;
>         background-color: white;
>      }
>      ...
>      </binary>
>      </sampleResult>
>     </sampleResult>
>     ...
>     </testResults>

14.6 XML Log format 2.1

> The format of the updated XML (2.1) is as follows (line breaks will be different):

>     <?xml version="1.0" encoding="UTF-8"?>
>     <testResults version="1.2">

>     -- HTTP Sample, with nested samples

>     <httpSample t="1392" lt="351" ts="1144371014619" s="true" lb="HTTP Request" rc="200" rm="OK" tn="Listen 1-1" dt="text" de="iso-8859-1" by="12407">
>       <httpSample t="170" lt="170" ts="1144371015471" s="true" lb="http://www.apache.org/style/style.css" rc="200" rm="OK" tn="Listen 1-1" dt="text" de="ISO-8859-1" by="1002">
>         <responseHeader class="java.lang.String">HTTP/1.1 200 OK
>     Date: Fri, 07 Apr 2006 00:50:14 GMT
>     ...
>     Content-Type: text/css
>     </responseHeader>
>         <requestHeader class="java.lang.String">MyHeader: MyValue</requestHeader>
>         <responseData class="java.lang.String">body, td, th {
>         font-size: 95%;
>         font-family: Arial, Geneva, Helvetica, sans-serif;
>         color: black;
>         background-color: white;
>     }
>     ...
>     </responseData>
>         <cookies class="java.lang.String"></cookies>
>         <method class="java.lang.String">GET</method>
>         <queryString class="java.lang.String"></queryString>
>         <url>http://www.apache.org/style/style.css</url>
>       </httpSample>
>       <httpSample t="200" lt="180" ts="1144371015641" s="true" lb="http://www.apache.org/images/asf_logo_wide.gif" rc="200" rm="OK" tn="Listen 1-1" dt="bin" de="ISO-8859-1" by="5866">
>         <responseHeader class="java.lang.String">HTTP/1.1 200 OK
>     Date: Fri, 07 Apr 2006 00:50:14 GMT
>     ...
>     Content-Type: image/gif
>     </responseHeader>
>         <requestHeader class="java.lang.String">MyHeader: MyValue</requestHeader>
>         <responseData class="java.lang.String">http://www.apache.org/images/asf_logo_wide.gif</responseData>
>           <responseFile class="java.lang.String">Mixed1.html</responseFile>
>         <cookies class="java.lang.String"></cookies>
>         <method class="java.lang.String">GET</method>
>         <queryString class="java.lang.String"></queryString>
>         <url>http://www.apache.org/images/asf_logo_wide.gif</url>
>       </httpSample>
>       <responseHeader class="java.lang.String">HTTP/1.1 200 OK
>     Date: Fri, 07 Apr 2006 00:50:13 GMT
>     ...
>     Content-Type: text/html; charset=ISO-8859-1
>     </responseHeader>
>       <requestHeader class="java.lang.String">MyHeader: MyValue</requestHeader>
>       <responseData class="java.lang.String">
>     ...
>     &lt;html&gt;
>      &lt;head&gt;
>     ...
>      &lt;/head&gt;
>      &lt;body&gt;
>     ...
>      &lt;/body&gt;
>     &lt;/html&gt;
>     </responseData>
>       <cookies class="java.lang.String"></cookies>
>       <method class="java.lang.String">GET</method>
>       <queryString class="java.lang.String"></queryString>
>       <url>http://www.apache.org/</url>
>     </httpSample>

>     -- nonHTTPP Sample

>     <sample t="0" lt="0" ts="1144372616082" s="true" lb="Example Sampler" rc="200" rm="OK" tn="Listen 1-1" dt="text" de="ISO-8859-1" by="10">
>       <responseHeader class="java.lang.String"></responseHeader>
>       <requestHeader class="java.lang.String"></requestHeader>
>       <responseData class="java.lang.String">Listen 1-1</responseData>
>       <responseFile class="java.lang.String">Mixed2.unknown</responseFile>
>       <samplerData class="java.lang.String">ssssss</samplerData>
>     </sample>

>     </testResults>

> Note that the sample node name may be either "sample" or "httpSample".

> The sample attributes have the following meaning:

> Attribute | Content
> t | elapsed time (ms)
> lt | latency (ms) - not all samplers support this
> ts | timeStamp
> s | Success
> lb | Label
> rc | Response Code
> rm | Response Message
> tn | Thread Name
> dt | Data type
> de | Data encoding
> by | Bytes
> ng | Number of active threads in this group
> na | Number of active threads for all thread groups

> Versions 2.1 and 2.1.1 of JMeter saved the Response Code as "rs", but read it back expecting to find "rc". This has been corrected so that it is always saved as "rc"; either "rc" or "rs" can be read.

14.7 Saving response data

> As shown above, the response data can be saved in the XML log file if required. However, this can make the file rather large, and the text has to be encoded so that it is still valid XML. Also, images cannot be included.
> Another solution is to use the Post-Processor Save_Responses_to_a_file . This generates a new file for each sample, and saves the file name with the sample. The file name can then be included in the sample log output. The data will be retrieved from the file if necessary when the sample log file is reloaded.

Index | Next | Prev

Copyright © 1999-2006, Apache Software Foundation | Updated: $Date: 2006-04-30 23:27:31 +0100 (Sun, 30 Apr 2006) $