# How can I redirect std::cout to Python Interactor?

**URL:** <https://discourse.slicer.org/t/how-can-i-redirect-std-cout-to-python-interactor/33378>\
**Category:** Development\
**Created:** [December 13, 2023, 7:32am UTC](https://discourse.slicer.org/t/how-can-i-redirect-std-cout-to-python-interactor/33378 "2023-12-13T07:32:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nnzzll](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/nnzzll/32/16350_2.png) [@nnzzll](https://discourse.slicer.org/u/nnzzll)\
**Post date:** [December 13, 2023, 7:32am UTC](https://discourse.slicer.org/t/how-can-i-redirect-std-cout-to-python-interactor/33378/1 "2023-12-13T07:32:55Z")

</div>

I’m developing a C++ extension and there are lots of output messages using “std::cout”.

However, I can only see these messages when slicer started from terminal and cannot see them in the python interactor.

How can I redirect those messages to python interactor?

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [December 13, 2023, 7:47am UTC](https://discourse.slicer.org/t/how-can-i-redirect-std-cout-to-python-interactor/33378/2 "2023-12-13T07:47:23Z")

</div>

Did you also consider looking at the `Error Log` ?

See [https://slicer.readthedocs.io/en/latest/user\_guide/user\_interface.html#application-menu](https://slicer.readthedocs.io/en/latest/user_guide/user_interface.html#application-menu)

This should list all messages.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/d/edecb97957e019b4dc6d090f34e8d696904ee9eb.png)

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [December 13, 2023, 9:52am UTC](https://discourse.slicer.org/t/how-can-i-redirect-std-cout-to-python-interactor/33378/3 "2023-12-13T09:52:40Z")

</div>

If you develop the extension then I assume you have control over the logging. In this case I’d suggest using VTK or Qt macros for logging (depending on whether your class is VTK or Qt based). I’m thinking about `vtk[Debug/Info/Warning/Error]Macro` and `qDebug/qWarning/qCritical`. These will appear in the Python console. Be mindful that you may need to lower the log level in Application Settings if you want to use `vtkInfoMacro` for example.
