B
B
beduin012018-02-06 12:36:03
Python
beduin01, 2018-02-06 12:36:03

How does a logger work in Python?

Suppose I have two modules app.py and foo.py
I understand correctly that it is enough for me to configure the logger in the app.py module like this:

logging.basicConfig(level=logging.INFO)
log = logging.getLogger()
handler = logging.handlers.SysLogHandler(address='/dev/log') # or logging.StreamHandler()
log.addHandler(handler)

After that, in order for my logger to work exactly as specified in the foo.py module, I just need to initialize it there:
log = logging.getLogger()
And will it use the settings from the app.py module or are there any nuances?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question