What are the steps to output the debug sampler's output to the JMeter log?

276    Asked by Amitraj in Cyber Security , Asked on Apr 22, 2022

 I have several JMeter variables that are read in from User-Defined Properties, read from a CSV, or extracted from an HTTP response.


I need to be able to output the variables in a log file, and want to include them in the jmeter.log for now. I know how to use the Debug Sampler to view them in the JMeter UI, but it does not seem that they are being saved to jmeter.log.


Is it possible to configure JMeter to log the output of the Debug Sampler in jmeter.log, and if so, how?

Answered by Al German

The easiest way to output the debug sampler's output to the JMeter log is using an appropriate JSR223 Test Element and simple Groovy script like:


vars.entrySet().each { var -> log.info(var.key + '=' + var.value) }
Where:
vars - stands for JMeterVariables class instance
log - is Log4JLogger

Your Answer

Interviews

Parent Categories