# Environment Logging

**URL:** <https://discuss.ray.io/t/environment-logging/6831>\
**Category:** RLlib\
**Created:** [July 14, 2022, 7:18pm UTC](https://discuss.ray.io/t/environment-logging/6831 "2022-07-14T19:18:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![evo11x](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/evo11x/32/2303_2.png) [@evo11x](https://discuss.ray.io/u/evo11x)\
**Post date:** [July 14, 2022, 7:18pm UTC](https://discuss.ray.io/t/environment-logging/6831/1 "2022-07-14T19:18:13Z")

</div>

After I train a custom environment I want to log the actions, rewards and a few additional parameters to see how the rewards are distributed in the environment.

Which of the following methods would be the best for logging?

1. Log to csv from inside the environment

2. Create a log environment wrapper derived from my custom environment

3. Add logging to the render function of the environment

4. Other method ?

The offline API output does not help very much because I need to add some additional parameters to log.

- Medium: It contributes to significant difficulty to complete my task, but I can work around it.

---

<div class="post-metadata">

**Author:** ![Lars\_Simon\_Zehnder](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/lars_simon_zehnder/32/1185_2.png) [@Lars\_Simon\_Zehnder](https://discuss.ray.io/u/Lars_Simon_Zehnder)\
**Post date:** [July 14, 2022, 7:30pm UTC](https://discuss.ray.io/t/environment-logging/6831/2 "2022-07-14T19:30:22Z")

</div>

@evo11x , you can log further parameters through the Offline API by adding the parameters to the environment `info` returned by the `step()` function or the policy `info` returned by `compute_actions()` function.

Later on you can use the [`JsonReader`](https://github.com/ray-project/ray/blob/60dd77a2d33e97fada16e0dd42962eb2db023ced/rllib/offline/json_reader.py#L126) to read the JSON data.

---

<div class="post-metadata">

**Author:** ![evo11x](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/evo11x/32/2303_2.png) [@evo11x](https://discuss.ray.io/u/evo11x)\
**Post date:** [July 14, 2022, 11:58pm UTC](https://discuss.ray.io/t/environment-logging/6831/3 "2022-07-14T23:58:56Z")

</div>

@Lars_Simon_Zehnder Thanks! It is easy to log with the env info parameter
