# Info level logging messages do not appear in Python console

**URL:** <https://discourse.slicer.org/t/info-level-logging-messages-do-not-appear-in-python-console/26418>\
**Category:** Development\
**Tags:** python\
**Created:** [November 24, 2022, 10:46am UTC](https://discourse.slicer.org/t/info-level-logging-messages-do-not-appear-in-python-console/26418 "2022-11-24T10:46:18Z")\
**Posts on this page:** 6\
**Page:** 1

<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:** [November 24, 2022, 10:46am UTC](https://discourse.slicer.org/t/info-level-logging-messages-do-not-appear-in-python-console/26418/1 "2022-11-24T10:46:18Z")

</div>

I built the latest Slicer 5.3, and I now see the changes in the Python console. It’s great to see Qt and VTK errors there too.

However, one thing that could make my day to day work very hard is that the output from `logging.info` calls in the executed code do not appear in the console. Is there any way to turn this back on? Thank you!

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [November 24, 2022, 12:35pm UTC](https://discourse.slicer.org/t/info-level-logging-messages-do-not-appear-in-python-console/26418/2 "2022-11-24T12:35:18Z")

</div>

Have you gone into application settings to change log level from the default Warning to Info?

> [@New feature: Python console displays more log messages](https://discourse.slicer.org/t/new-feature-python-console-displays-more-log-messages/25739):
>
> Until now, the Python console only displayed Python outputs and Python log messages. Therefore, if a Python command executed a VTK method and that VTK method logged an error or warning, it was not immediately visible for the developer (the developer had to notice the change in the log icon, click on it, and scroll down to see the new message). In latest Slicer Preview Release (Slicer 5.1.0-2022-10-15 and later), the Python console displays log messages from all sources - Python, Qt, VTK, ITK. F…

---

<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:** [November 24, 2022, 1:19pm UTC](https://discourse.slicer.org/t/info-level-logging-messages-do-not-appear-in-python-console/26418/3 "2022-11-24T13:19:58Z")

</div>

That was easy then, thanks. I thought it would be a CMake option or something similar, that’s why I asked.

I’m wondering why warning is the default log level instead of info? The difference between debug and info is that although neither of them indicate errors, the debug messages don’t appear in the console but the info ones do. Now if you don’t change the setting, there is no difference between the two.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 24, 2022, 2:21pm UTC](https://discourse.slicer.org/t/info-level-logging-messages-do-not-appear-in-python-console/26418/4 "2022-11-24T14:21:33Z")

</div>

Logging and process output in Python were previously somewhat intermixed, as it was not possible to print a message on the Python console without making that also show up in the process output and therefore in the application log. After the logging system rework, it has become possible to clearly separate logs, process output, and Python console output, which allowed to display log messages from any sources (Qt, VTK, ITK, CTK, …) in the Python console.

We just had to decide what log level to display in the Python console. Since debug and info messages usually not that important and anything that we want to appear in the process output can be displayed using `print`, we decided the default log level to be warning and make it easy to change it in application settings.

If you want to display messages in the Python console from Python code, then I would recommend following options (which are the standard way of doing this in Python):

- A. register an additional Python logger, which prints info-level messages to the process output/Python console (if this is information that user might be interested in), or
- B. use `print` instead of `logging.info` (if users must see it, because for example that is the result of the command, not just some additional optional information).

---

<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:** [November 24, 2022, 2:45pm UTC](https://discourse.slicer.org/t/info-level-logging-messages-do-not-appear-in-python-console/26418/5 "2022-11-24T14:45:34Z")

</div>

Thanks for the answer! After setting the level (as you said, easily) to info, I can see what I want in the console - I usually info-log the main steps in my modules, and it’s easy to see where errors occured, if the values are still sensible etc.

By the way I expect way more work happening in the future about fixing errors, just so that they don’t clog up the console 🙂

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 15, 2023, 5:10am UTC](https://discourse.slicer.org/t/info-level-logging-messages-do-not-appear-in-python-console/26418/6 "2023-11-15T05:10:58Z")

</div>

A post was split to a new topic: [Print output does not immediately appear in Python console](https://discourse.slicer.org/t/print-output-does-not-immediately-appear-in-python-console/32825)
