Place the "global" variable in the "settings" module.
settings.py
log_file = "/path/to/file"
main.py
import settings import logging logging.basicConfig(filename=settings.log_file,level=logging.DEBUG) logging.debug("This should go to the log file")
other_module.py
import logging logging.debug("This is a message from another place.")
While the log module can solve your immediate problem and many others, the settings module template is useful for many other things besides the log file names. It is used by Django to configure almost everything.
Terrel shumway
source share