# Sending error messages from python

**URL:** <https://discourse.slicer.org/t/sending-error-messages-from-python/24376>\
**Category:** Development\
**Created:** [July 18, 2022, 6:09pm UTC](https://discourse.slicer.org/t/sending-error-messages-from-python/24376 "2022-07-18T18:09:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![keri](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/keri/32/11618_2.png) [@keri](https://discourse.slicer.org/u/keri)\
**Post date:** [July 18, 2022, 6:09pm UTC](https://discourse.slicer.org/t/sending-error-messages-from-python/24376/1 "2022-07-18T18:09:47Z")

</div>

Hi,

As I can see there are at least two ways of sending errors from scripted modules:

- logging.error()
- qt.qCritical()

Which is the preferred one?

Also does Slicer write logs somewhere in the text file? For example if my app crash I would like to see the logs.

---

<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:** [July 18, 2022, 7:20pm UTC](https://discourse.slicer.org/t/sending-error-messages-from-python/24376/2 "2022-07-18T19:20:04Z")

</div>

From python, you should use the `logging` module.

Consider reading these sections:

- [Style Guide / Logging](https://slicer.readthedocs.io/en/latest/developer_guide/style_guide.html?highlight=logging#logging)
- [Style Guide / Error and warning messages](https://slicer.readthedocs.io/en/latest/developer_guide/style_guide.html#error-and-warning-messages)

---

<div class="post-metadata">

**Author:** ![keri](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/keri/32/11618_2.png) [@keri](https://discourse.slicer.org/u/keri)\
**Post date:** [July 18, 2022, 8:35pm UTC](https://discourse.slicer.org/t/sending-error-messages-from-python/24376/3 "2022-07-18T20:35:31Z")

</div>

Just to clarify, does Slicer somehow write logs to file?

---

<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:** [July 18, 2022, 8:56pm UTC](https://discourse.slicer.org/t/sending-error-messages-from-python/24376/4 "2022-07-18T20:56:10Z")

</div>

> [@keri](#):
>
> somehow write logs to file?

It does, see `Log outputs` link referenced in the [User Guide](https://slicer.readthedocs.io/en/latest/user_guide/settings.html#id1)

---

<div class="post-metadata">

**Author:** ![keri](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/keri/32/11618_2.png) [@keri](https://discourse.slicer.org/u/keri)\
**Post date:** [July 18, 2022, 9:01pm UTC](https://discourse.slicer.org/t/sending-error-messages-from-python/24376/5 "2022-07-18T21:01:56Z")

</div>

Thank you very much!
