# Logging value after exiting the loop

**URL:** https://community.gatling.io/t/logging-value-after-exiting-the-loop/5748
**Category:** Gatling (Open-Source)
**Created:** [August 6, 2020, 9:28pm UTC](https://community.gatling.io/t/logging-value-after-exiting-the-loop/5748 "2020-08-06T21:28:03Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Stefania\_Dabek](https://avatars.discourse-cdn.com/v4/letter/s/ec9cab/32.png) [@Stefania\_Dabek](https://community.gatling.io/u/Stefania_Dabek)
#### Post date: [August 6, 2020, 9:28pm UTC](https://community.gatling.io/t/logging-value-after-exiting-the-loop/5748/1 "2020-08-06T21:28:03Z")

</div>

Hi,

In my current project we use following loop:

.asLongAsDuring(session =\> session(“currentResponseStatus”).as[String] != “200”, GlobalVariables.timeout) { exec … }

We’d want to log an information in the console when the loop exits after timeout. Is there any possibility to do this? I couldn’t find any callback or something like that to use in such case.

I will be grateful for any case or suggestion of a solution.

Best regards,  
Stefania

---

<div class="post-metadata">

### Author: ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)
#### Post date: [August 7, 2020, 7:24am UTC](https://community.gatling.io/t/logging-value-after-exiting-the-loop/5748/2 "2020-08-07T07:24:57Z")

</div>

What don’t you print after the loop?

asLongAsDuring() {???)  
.exec { session =\>  
println(session(“currentResponseStatus”).as[String])  
session  
}

---

<div class="post-metadata">

### Author: ![Stefania\_Dabek](https://avatars.discourse-cdn.com/v4/letter/s/ec9cab/32.png) [@Stefania\_Dabek](https://community.gatling.io/u/Stefania_Dabek)
#### Post date: [August 7, 2020, 7:58am UTC](https://community.gatling.io/t/logging-value-after-exiting-the-loop/5748/3 "2020-08-07T07:58:07Z")

</div>

Stephane,

Cause it doesn’t cover the case I’ve described. I only want to do sth like:  
.asLongAsDuring(session =\> session(“currentResponseStatus”).as[String] != “200”, GlobalVariables.timeout) { … }  
If (timeout occurs) then printl (“Maximum response time reached”).

I want to differ cases when the request cannot be processed by the system in a given time from the rest of the requests.

Kind regards,  
Stefania

---

<div class="post-metadata">

### Author: ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)
#### Post date: [August 7, 2020, 8:03am UTC](https://community.gatling.io/t/logging-value-after-exiting-the-loop/5748/4 "2020-08-07T08:03:35Z")

</div>

If status is not 200, it means timeout was reached, right? Or am I missing something?
