Creation of logs in a file

mac08_flo
New Contributor

Good afternoon.

I am trying to add logs in the creation of my code. The issue is that I haven't yet found a way to write the logs to a separate file, rather than having them output to the terminal; I want them to be stored in a file (example.log).

I have tried using basicConfig and specifying the path where I want to store the logs, but they are not being saved.

Could you help me? Am I missing some configuration, or do you know of any other way to store the logs?

filipniziol
Esteemed Contributor

Hi @mac08_flo ,

Use logging library. You can configure to log to terminal, to files etc.
https://www.highlight.io/blog/5-best-python-logging-libraries