naqushab
naqushab

Reputation: 804

Logging to a single file across different modules in python

I have a python project where I want to log multiple events across different modules in a single rotating file. I am using logzero for this.

For example: If I need logging from init.py and main.py, how can I using only a single log file to log both the events?

Upvotes: 1

Views: 409

Answers (1)

Sergi Pasoevi
Sergi Pasoevi

Reputation: 2851

You can specify the same log file from different python files:

logzero.logfile("logfile.log", maxBytes=1000000, backupCount=3)

It is mentioned in the documentation (Features section):

Multiple loggers can write to the same logfile (also across multiple Python files).

Upvotes: 2

Related Questions