# Large discrepancy in logged output in Python vs. Bash Consoles

**URL:** https://discourse.slicer.org/t/large-discrepancy-in-logged-output-in-python-vs-bash-consoles/43783
**Category:** Support
**Tags:** python
**Created:** [July 20, 2025, 12:55pm UTC](https://discourse.slicer.org/t/large-discrepancy-in-logged-output-in-python-vs-bash-consoles/43783 "2025-07-20T12:55:30Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![SomeoneInPart](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@SomeoneInPart](https://discourse.slicer.org/u/SomeoneInPart)
#### Post date: [July 20, 2025, 12:55pm UTC](https://discourse.slicer.org/t/large-discrepancy-in-logged-output-in-python-vs-bash-consoles/43783/1 "2025-07-20T12:55:30Z")

</div>

For ease of testing a WIP module, I will often start Slicer from a bash shell, so that I could save its output to a log programmatically. However, when I went to refactor my many `print` statements into `logging` calls, I noticed that they no longer appeared. Digging deeper, it seems that calling Slicer from the command line results in a pretty substantial de-sync.

For reference:

The bash console’s output:

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

Slicer’s Python Console:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/c/a/ca449c2db5230aa61ed71f25d5b441890efa05cc.png)

The code in question:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/c/1/c1efeefcc2a2bdfa71ac9f633705fb14d0465570.png)

Far as I can tell, the following is happening:

- `Qt` logs are properly displayed in both the Python and Bash console
- `print` statements are only shown in the Bash console
- `logging` statements are only shown in the Python console

Is their something I’m missing? This is on Slicer 5.8.1, called within a `ScriptedLoadableModuleWidget` and `VTKObservationMixin` subclass, with `get_cart_logger` simply being a wrapper for a `logging.getLogger` call with some tracking strapped on. Any insight on this would be appreciated.

---

<div class="post-metadata">

### Author: ![SomeoneInPart](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@SomeoneInPart](https://discourse.slicer.org/u/SomeoneInPart)
#### Post date: [July 21, 2025, 1:42am UTC](https://discourse.slicer.org/t/large-discrepancy-in-logged-output-in-python-vs-bash-consoles/43783/2 "2025-07-21T01:42:43Z")

</div>

Slight correction; only _some_ of the `QT` logs are placed in the Bash console; the “green” logs are Python only, further confusing things.

---

<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: [July 21, 2025, 2:05am UTC](https://discourse.slicer.org/t/large-discrepancy-in-logged-output-in-python-vs-bash-consoles/43783/3 "2025-07-21T02:05:41Z")

</div>

Have you tried adjusting the user setting for the logging level on the python console? See the following linked thread below:

> [@Info level logging messages do not appear in Python console](https://discourse.slicer.org/t/info-level-logging-messages-do-not-appear-in-python-console/26418):
>
> 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: ![SomeoneInPart](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@SomeoneInPart](https://discourse.slicer.org/u/SomeoneInPart)
#### Post date: [July 21, 2025, 2:12am UTC](https://discourse.slicer.org/t/large-discrepancy-in-logged-output-in-python-vs-bash-consoles/43783/4 "2025-07-21T02:12:03Z")

</div>

Thank you for your response. I did check that; my “Log level” is currently set to Debug:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/f/4f0bc009cd8cb55b0086c4c54fd5232b5200848f.png)

This is also an `ERROR` level logging message, so it should appear for any logging whatsoever. And it does; but only in the Python console, not Bash.

---

<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: [July 22, 2025, 9:34am UTC](https://discourse.slicer.org/t/large-discrepancy-in-logged-output-in-python-vs-bash-consoles/43783/5 "2025-07-22T09:34:13Z")

</div>

Console is only available in certain environments (e.g., no console on Windows GUI applications), so Slicer does not depend on it and I would not recommend for debugging.

You can access logs in the application log file (`slicer.app.errorLogModel().filePath`). You can also add a callback function to the error log model object to get notified when something is logged and can get any log messages like this:

```python
def onEntryAdded(datetime, threadId, logLevel, origin, context, text):
    slicer.util.messageBox(f"[{datetime.toString()}] [{origin}] ({logLevel}) {text}")

slicer.app.errorLogModel().connect('entryAdded(QDateTime,QString,ctkErrorLogLevel::LogLevel,QString,ctkErrorLogContext,QString)', onEntryAdded)

```

---

<div class="post-metadata">

### Author: ![SomeoneInPart](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@SomeoneInPart](https://discourse.slicer.org/u/SomeoneInPart)
#### Post date: [July 22, 2025, 6:31pm UTC](https://discourse.slicer.org/t/large-discrepancy-in-logged-output-in-python-vs-bash-consoles/43783/6 "2025-07-22T18:31:35Z")

</div>

Ah; I was wondering how to access that message box. Will start pivoting to that then; thank you!
