Log gatling-session on test failure


We have a simulation, and if a request fails, we want to log the gatling-session object to easily find the username and other info about the current user.

Is this possible to do in gatling? What we want is something like “execute this block when the request fails”, or “execute this block when a check fails”.

Henrik Wingerei


Since 2.0.0-M1, infoExtractor hook takes a Session parameter:

There’s also a builtin that adds the Session content to simulation.log records when the request fails.

You can adapt this example if you just want to log with logback.

class MySimulation extends Simulation with Logging {

def logSessionOnFailure(status: RequestStatus, session: Session, request: Request, response: ExtendedResponse): List[String] = {
if (status == KO) logger.error(session)

val httpConf = http





Thanks! I’ll look into it!

Is something similar possible in 1.5.0 as well? We’re currently using that version on the project I’m working on.


kl. 14:20:38 UTC+2 mandag 13. mai 2013 skrev Stéphane Landelle følgende:

Sadly no: the hook before Gatling 2 doesn’t take the session.

Ok. I’ll see whether it’s possible to upgrade the project.

Just to be clear: There are no ways in 1.5.X to execute any “custom” code (written in the simulation) when a request fails? For example, if we want to execute a block of code.

kl. 14:35:42 UTC+2 mandag 13. mai 2013 skrev Stéphane Landelle følgende:

Nope, sorry…

Actually, that’s something we could easily add to log triggered on request failure: https://github.com/excilys/gatling/wiki/Configuration#wiki-config-files
If that would meet your needs, please open an issue and we’ll add it for 1.5.1.



That would definitely help us!

Created the following issue: https://github.com/excilys/gatling/issues/1160


kl. 15:14:37 UTC+2 mandag 13. mai 2013 skrev Stéphane Landelle følgende:

Done! Will be in 1.5.1 and 2.0.0-M3.

Thanks! Impressive response time you guys have!

Any idea of when 1.5.1 will be released?


kl. 00:58:53 UTC+2 tirsdag 14. mai 2013 skrev Stéphane Landelle følgende:

Probably next week.