# Function Logs in Pocket IC (Rollback Testing)

**URL:** <https://forum.dfinity.org/t/function-logs-in-pocket-ic-rollback-testing/41374>\
**Category:** Rust\
**Created:** [February 19, 2025, 10:36am UTC](https://forum.dfinity.org/t/function-logs-in-pocket-ic-rollback-testing/41374 "2025-02-19T10:36:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jyotirmaygithub](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jyotirmaygithub/32/23999_2.png) [@jyotirmaygithub](https://forum.dfinity.org/u/jyotirmaygithub)\
**Post date:** [February 19, 2025, 10:36am UTC](https://forum.dfinity.org/t/function-logs-in-pocket-ic-rollback-testing/41374/1 "2025-02-19T10:36:08Z")

</div>

How can I configure PocketIC to capture and display the logs (e.g., `println!`, `ic_cdk::println!`, or `log!` statements) from a function when it executes within a test case? I want to ensure that when a function runs in PocketIC, its logs appear in the test output, helping to debug or showcase rollbacks testing effectively.

**For clarification:** Pocket IC is running fine with other stuff so there is nothing basic to be included.

Are there any dependencies, configurations, or Cargo.toml additions required to achieve this?

---

<div class="post-metadata">

**Author:** ![mraszyk](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/mraszyk/32/7945_2.png) [@mraszyk](https://forum.dfinity.org/u/mraszyk)\
**Post date:** [February 19, 2025, 11:39am UTC](https://forum.dfinity.org/t/function-logs-in-pocket-ic-rollback-testing/41374/2 "2025-02-19T11:39:54Z")

</div>

You can retrieve _canister_ logs using the [function](https://github.com/dfinity/ic/blob/5d0fcce4072ee99c054310a5bed01603780e89b0/packages/pocket-ic/src/lib.rs#L788) `fetch_canister_logs`. In any case, canister logs (e.g., `ic_cdk::print`) also appear in the PocketIC server output. Using `println!` in canister code is a no-op.

---

<div class="post-metadata">

**Author:** ![AliSci](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/alisci/32/33799_2.png) [@AliSci](https://forum.dfinity.org/u/AliSci)\
**Post date:** [August 7, 2025, 7:42am UTC](https://forum.dfinity.org/t/function-logs-in-pocket-ic-rollback-testing/41374/3 "2025-08-07T07:42:16Z")

</div>

U can ` const picServer = await PocketIcServer.start({

```
  showCanisterLogs: true,

```

showRuntimeLogs: true,

```
});

```

`but where to find the logs ?`  
`should i `console.log({canisterLogs:picServer.canisterLogs()})?

---

<div class="post-metadata">

**Author:** ![mraszyk](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/mraszyk/32/7945_2.png) [@mraszyk](https://forum.dfinity.org/u/mraszyk)\
**Post date:** [August 7, 2025, 11:43am UTC](https://forum.dfinity.org/t/function-logs-in-pocket-ic-rollback-testing/41374/4 "2025-08-07T11:43:01Z")

</div>

You should find the logs in the stderr of the process that runs your tests.
