Print correlation values on console in gatling

UmeshPathak picture UmeshPathak · May 12, 2016 · Viewed 11.6k times · Source

How can we print the values captured using saveAs("myValue") on the console of gatling, like we do System.out.println() in Java?

Answer

cvakiitho picture cvakiitho · May 13, 2016

Values saved with saveAs, are saved into session : Docs : http://gatling.io/docs/2.2.0/session/session_api.html#id2

Those values are actually logged into console automatically if you turn logging on in settings: resources/logback.xml uncomment :

<logger name="io.gatling.http.ahc" level="TRACE" /> 
<logger name="io.gatling.http.response" level="TRACE" /> 

With this settings you will see this before each reqest:

Session: Session(<Session desc.>,5846298469383031361-23,Map(<session vars>),1463134760217,8,KO,List(),<function1>)

Or you have to print your vars in session function:

val printSesssionVar = scenario("print session var").exec{
    session =>
      println(session("<your session var>").as[String])
      session
  }