3

Adding config file to package is not a big deal. But when I upload package to pypi and install it, it's not possible to read logging config:

logging.config.fileConfig('logging.conf')

basically my modules don't find it because file is not in current working directory anymore. How can I address that?

Pavel Paulau
  • 786
  • 2
  • 7
  • 19

1 Answers1

3

If logging.conf exists in the same directory as the file calling logging.config.fileConfig, then you could use:

import os
logconf_file = os.path.join(os.path.dirname(__file__), 'logging.conf')
logging.config.fileConfig(logconf_file)
unutbu
  • 842,883
  • 184
  • 1,785
  • 1,677