Getting below error in log:
2020-06-24 13:23:51,091 ERROR o.a.j.u.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: //to output the execution flow in the jmeter.log to help demonstrate how the scr . . . '' : Typed variable declaration : Attempt to resolve method: getName() on undefined variable or class name: sampler 2020-06-24 13:23:51,091 WARN o.a.j.e.BeanShellPostProcessor: Problem in BeanShell script: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: //to output the execution flow in the jmeter.log to help demonstrate how the scr . . . '' : Typed variable declaration : Attempt to resolve method: getName() on undefined variable or class name: sampler 2020-06-24 13:23:51,154 ERROR o.a.j.u.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: //to output the execution flow in the jmeter.log to help demonstrate how the scr . . . '' : Typed variable declaration : Attempt to resolve method: getName() on undefined variable or class name: sampler 2020-06-24 13:23:51,154 WARN o.a.j.e.BeanShellPostProcessor: Problem in BeanShell script: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: //to output the execution flow in the jmeter.log to help demonstrate how the scr . . . '' : Typed variable declaration : Attempt to resolve method: getName() on undefined variable or class name: sampler 2020-06-24 13:23:51,236 ERROR o.a.j.u.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: //to output the execution flow in the jmeter.log to help demonstrate how the scr . . . '' : Typed variable declaration : Attempt to resolve method: getName() on undefined variable or class name: sampler 2020-06-24 13:23:51,236 WARN o.a.j.e.BeanShellPostProcessor: Problem in BeanShell script: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of://to output the execution flow in the jmeter.log to help demonstrate how the scr . . . '' : Typed variable declaration : Attempt to resolve method: getName() on undefined variable or class name: sampler
Below is the code used in Beanshell postprocessor.
import java.text.DecimalFormat;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
int tdNumber = ctx.getThreadNum();
int noThreads = ctx.getThreadGroup().getNumThreads();
long tdstart = ctx.getThread().getStartTime();
long tdEnd = ctx.getThread().getEndTime();
String respCode = ctx.getPreviousResult().getResponseCode();
String respCode = ctx.getPreviousResult().getResponseMessage();
String samplerName = sampler.getName();
Date date = new Date();
date.setDate(date.getDate());
SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");
String formattedDate = df.format(date);
log.info("sampler::"+ sampleName +"....ThreadNo::"+ (tdNumber + 1) +" ....Starttime::"+ formattedDate +
"....StatusCode::" + respCode +"....TotalThreads::"+ noThreads +" ....Iterationno::"+vars.getIteration());