1

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?

1
  • 1
    I don't know how you structured your code, but did you think about passing the logger object as argument to the several classes (maybe to __int__(self, logger)) or define it as constant in my_logger.py for example. Commented Dec 19, 2017 at 12:09

1 Answer 1

2

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).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.