Reputation: 165
I use configparser to read some configuration options for my application and I'd like to read the logging configuration as well.
Can I do that in the same file? How should I name the logging specific sections?
Upvotes: 2
Views: 1635
Reputation: 165
I'll answer my own question since the advice from @chepner helped.
Considering the python documentation, I could just pass the object the configparser.ConfigParser
creates as argument to the logging.config.fileConfig
function
Here is the snipper:
config = configparser.ConfigParser()
config['general'] = {'default-option': 'blah'}
config.read(configFile)
# Logging configuration
logging.config.fileConfig(config, disable_existing_loggers=False)
Upvotes: 4