title: Jmeter - how to output extra info (jmeter variable(s)) on Response Assertion failure
body: <p>So I added a Response Assertion on the main sample and apply to that and all sub-samples. I assert its a good Response Code, so the assertion will fail Response codes like 4xx and 5xx errors.
  I'm curious, I store a user_id in a jmeter variable when a new user is created in my load script (which is available in jmeter for the entire thread/samplers/session)... Is there anyway i can output that variable via the Beanshell for <strong>All</strong> sampler requests <strong>ONLY IF</strong> there is an Error.</p>
  
  <p>I already output user_id earlier for ALL requests right after creating a user via something like so:</p>
  
  <pre><code>log.info("user_id:"+ vars.get("user_id") ); //gotten via JSON Path PostProcessor earlier when creating User.
  </code></pre>
  
  <p>But I'd like do output something like so for all Response Assertion errors:</p>
  
  <pre><code>log.info("Response Assertion failure for user_id:"+ vars.get("user_id") );
  </code></pre>
  
  <p>maybe a 'BeanShell Post Processor' but dont really have a good idea how to hook that into the 1 Response Assertion whick checks the whole Thread Group so it only outputs to the log the user_id dynamically if there is Assertion failure.</p>
  
  <p>Is there a worst case scenario, where I cant do it for all requests at the 'top level' of the Thread Group... but maybe I'd have to add Response Assertions on each request instead and only then I can dynamically add the output somehow?
  (But if there is a way of doing it once for all requests would be cool/better)
  Any ideas are welcome, Thanks!</p>