On Wed, Dec 23, 2020 at 1:19 PM Felix Schumacher <felix.schumac...@internetallee.de> wrote: > > > Am 23.12.20 um 19:16 schrieb Tong Sun: > > Hi, > > > > Most people would have some Java code to support JMeter test scripts. > > How to print stack trace for the Java code when something went wrong? > > > > I tried: > > > > try { > > // some code > > } catch(Error e) { > > log.error("Error: $e") > > log.info("${org.codehaus.groovy.runtime.StackTraceUtils.sanitize(new > > Exception(e)).printStackTrace()}") > > } > > > > base on > > https://stackoverflow.com/questions/6259202/how-do-i-print-a-groovy-stack-trace > > and also `e.printStackTrace()` from Java, but both print out just "null" > > Where would you place those code? If you use that inside of JMeter > JSR-223 scripts, you will get bitten by JMeter replacing the ${...} stuff.
Yeah, exactly in the JSR-223 scripts. I put merely org.codehaus.groovy.runtime.StackTraceUtils.sanitize(new Exception(e)).printStackTrace() before but nothing get printed in log, so I changed to log.info instead. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@jmeter.apache.org For additional commands, e-mail: user-h...@jmeter.apache.org