Reputation: 160
For purpose of better understanding/analyzing JMeter logs I'd like to add loop count to Simple Data Writer log record. I could have an loop count variable easily, but how to add variable value to Simple Data Writer record?
E.g. in my JMeter test I have 50 users, which e.g. ramping up slowly like each 5 mins new user. And my threadgroup is configured to loop forever during test run. So I have SDW records like:
1447625139724,20,157 /Start.aspx,200,OK,Thread Group - Dashboard 50 1-1,text,true,3418,1,1,6,0,0
...
1447625158283,42,171 /Logout.aspx,200,OK,Thread Group - Dashboard 50 1-1,text,true,6814,1,1,32,0,0
1447625160283,13,157 /Start.aspx,200,OK,Thread Group - Dashboard 50 1-1,text,true,3419,1,1,4,0,0
...
...
1447625201195,1023,160 /Start.aspx,200,OK,Thread Group - Dashboard 50 1-2,text,true,24038,2,2,29,0,0
...
So at the end I have 50 threads running. And withing each thread users login - do things - logout - log back in ...
What I would like to see in log file is not only "Thread Group - Dashboard 50 1-2" but something like "Thread Group - Dashboard 50 1-2-15" where 15 would mean 15th loop for thread 2 in thread group 1.
I know I can make a counter variable and increment it e.g. each /Start call. But how do I write value of that variable with each Simple Data Writer record? That is the question!
Thank you.
Upvotes: 0
Views: 3001
Reputation: 168217
Use JMeter's sample_variables property:
Add the following line to user.properties file (located under /bin folder of your JMeter installation)
sample_variables=counter,threadGroup,etc.
You can also provide this property via -J command line argument like:
jmeter -Jsample_variables=foo,bar -n -t testplan.jmx -l results.jtl
See Apache JMeter Properties Customization Guide for some extra information on the domain.
Upvotes: 1
Reputation: 23805
Add a beanshell element to your test, preprocessor, postprocessor or sampler, doesn't really matter and add a log line to it, to write to JMeter log.
log.info("Hello World!");
You can write values of variables and jmeter properties to log as well. You can get a lot of run time information from JMeter context
log.info(ctx.getThreadNum() + "-" + vars.get("LoopCounterVariable"));
LoopCounterVariable
can be your own variable that you're updating, or you can add a JMeter counter to your test plan.
Upvotes: 0