# Logging or Printing information somewhere

**URL:** <https://forum.pioreactor.com/t/logging-or-printing-information-somewhere/87>\
**Category:** Software\
**Created:** [March 22, 2023, 11:56pm UTC](https://forum.pioreactor.com/t/logging-or-printing-information-somewhere/87 "2023-03-22T23:56:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![realPeteDavidson](https://forum.pioreactor.com/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@realPeteDavidson](https://forum.pioreactor.com/u/realPeteDavidson)\
**Post date:** [March 22, 2023, 11:56pm UTC](https://forum.pioreactor.com/t/logging-or-printing-information-somewhere/87/1 "2023-03-22T23:56:53Z")

</div>

I’m trying to test some code (a job), and this job has a method that is called via RepeatedTimer. How can I print out some information somewhere that I can see? For example, I see these messages sometimes:

2023-03-22T12:26:48-0700 DEBUG [background\_job] Disconnected from MQTT with rc=7: The connection was lost.  
2023-03-22T12:26:49-0700 INFO [background\_job] Reconnected to the MQTT broker on leader.

How can I create these messages, and if the answer is through events, can you provide a short description of how I can use the events? I’m not worried about storing the data yet, I am more interested in using this to print out some information when certain functions run to check how the code is running.

```auto
job = MyJob()
main_loop = RepeatedTimer(60, job.main_loop).start()
job.block_until_disconnected()

```

---

<div class="post-metadata">

**Author:** ![CamDavidsonPilon](https://forum.pioreactor.com/user_avatar/forum.pioreactor.com/camdavidsonpilon/32/3_2.png) [@CamDavidsonPilon](https://forum.pioreactor.com/u/CamDavidsonPilon)\
**Post date:** [March 23, 2023, 12:06am UTC](https://forum.pioreactor.com/t/logging-or-printing-information-somewhere/87/2 "2023-03-23T00:06:54Z")

</div>

On any `BackgroundJob` subclass, you can access the `logger` property:

```python
x = 3.1415
job.logger.debug("what is {x}?")
# 2023-03-22T12:26:49-0700 DEBUG [background_job] what is 3.1415?

```

---

<div class="post-metadata">

**Author:** ![CamDavidsonPilon](https://forum.pioreactor.com/user_avatar/forum.pioreactor.com/camdavidsonpilon/32/3_2.png) [@CamDavidsonPilon](https://forum.pioreactor.com/u/CamDavidsonPilon)\
**Post date:** [March 23, 2023, 12:08am UTC](https://forum.pioreactor.com/t/logging-or-printing-information-somewhere/87/3 "2023-03-23T00:08:18Z")

</div>

If you wanted to log _without_ a background job, that’s possible too:

```python
from pioreactor.logging import create_logger

logger = create_logger("my_script")
logger.debug(...)

```

---

<div class="post-metadata">

**Author:** ![realPeteDavidson](https://forum.pioreactor.com/letter_avatar_proxy/v4/letter/r/9d8465/32.png) [@realPeteDavidson](https://forum.pioreactor.com/u/realPeteDavidson)\
**Post date:** [March 23, 2023, 12:08am UTC](https://forum.pioreactor.com/t/logging-or-printing-information-somewhere/87/4 "2023-03-23T00:08:46Z")

</div>

Thanks! This is helpful.
