# How to log variable value of environment variable

**URL:** <https://community.postman.com/t/how-to-log-variable-value-of-environment-variable/15828>\
**Category:** Help Hub\
**Created:** [September 13, 2020, 1:37pm UTC](https://community.postman.com/t/how-to-log-variable-value-of-environment-variable/15828 "2020-09-13T13:37:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bgehrer](https://avatars.discourse-cdn.com/v4/letter/b/ac8455/32.png) [@bgehrer](https://community.postman.com/u/bgehrer)\
**Post date:** [September 13, 2020, 1:37pm UTC](https://community.postman.com/t/how-to-log-variable-value-of-environment-variable/15828/1 "2020-09-13T13:37:35Z")

</div>

Hi there

I’ve a very basic question about logging of environment variables. I’ve defined 2 env. variables in my pre request script and both of them are well taken into the Body of my Post request. The only problem is that i can’t log both of the variables as I recieve always the error that the 2nd variable isn’t defined. I defined it in the environment AND in the pre-request script, but i can’t log it.

Can anybody help me with that…it’s certainly just a syntax error…

My pre-request script:

_const transactionId = Math.floor((Math.random() \* 100) + 1);_

_pm.environment.set(“transactionId”,transactionId);_

_pm.environment.set(“transactionIdEnv”, “BASKALT-”);_

_console.log(transactionIdEnv,transactionId);_

In the console output i recieve “ReferenceError: transactionIdEnv is not defined” - When i delete the console entry or i delete just my env. variable transactionIdEnv in the brackets , the request is well generated and sent…?!

My goal is to have both values logged, one after the other (transactionIdEnv+transactionId)

Thanks a lot for your help!

Benjamin

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [September 13, 2020, 2:32pm UTC](https://community.postman.com/t/how-to-log-variable-value-of-environment-variable/15828/2 "2020-09-13T14:32:51Z")

</div>

To log out the environment variable, you would need to do this:

```auto
console.log(pm.environment.get('transactionIdEnv')) 

console.log(transactionId)

```

---

<div class="post-metadata">

**Author:** ![bgehrer](https://avatars.discourse-cdn.com/v4/letter/b/ac8455/32.png) [@bgehrer](https://community.postman.com/u/bgehrer)\
**Post date:** [September 14, 2020, 5:34am UTC](https://community.postman.com/t/how-to-log-variable-value-of-environment-variable/15828/3 "2020-09-14T05:34:42Z")

</div>

Thanks a lot Danny! Thats working pretty well…

Greetings Benjamin
