Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the complete log for bean shell scripts in jmeter

I am using Apache JMeter 3.1 and in my test suite I have a BeanShell PreProcessor. When I run the scrip, in the Log Viewer I can see there are errors in the bean shell script. But the error message is very limited, how can I get the complete error?

For example, an error I see in the Log Viewer is as follows,

ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: ``// Following is a sample for input // "abc.org/def/xyz . . . ''

Is there a way I can retrieve the complete error?

like image 611
Kalpa Welivitigoda Avatar asked Feb 01 '17 17:02

Kalpa Welivitigoda


People also ask

Where are JMeter logs?

You can view the log entries through the log viewer panel available in the JMeter IDE. The panel can be launched/closed by clicking either Options → Log Viewer menu item or by clicking the icon in the top right corner. The log levels can be set through the Options→ Log Level menu item.

What is BeanShell assertion in JMeter?

Beanshell Assertion – An advanced assertion with full access to JMeter API. Java conditional logic can be used to set the assertion result. __Beanshell Function – A JMeter Function that allows execution of custom BeanShell code during a sampler run.

What is CTX in JMeter?

ctx is the most powerful variable exposed to BeanShell. It represents the JMeterContext class, which is virtually JMeter itself. It provides read/write access to the underlying JMeter engine, samplers, and their results as well as variables/properties.

What is the use of JSR223 PostProcessor in JMeter?

The JSR223 postprocessor allows you to use precompiled scripts within test plans. The fact that the scripts are compiled before they are actually used brings a significant performance boost compared to other postprocessors.


1 Answers

You can enable debug output in at least 2 ways:

  • Adding debug() directive to the beginning of your Beanshell script - debugging output will go to STDOUT (JMeter console)
  • Putting your code inside the try block like:

    try {
        //your code here
    }
    catch (Throwable ex) {
        log.error("Something went wrong", ex);
        throw ex
    }
    

    This way full exception stacktrace will be available in jmeter.log file

I would rather recommend switching to JSR223 Elements and Groovy language as Groovy is more Java-compliant and provides better performance. See Groovy Is the New Black for details.

like image 107
Dmitri T Avatar answered Sep 22 '22 12:09

Dmitri T