Skip to content

Is there a way to disable dotted_lookup globally #685

@thomas-mckay

Description

@thomas-mckay

Env:
Python 3.9.6
DynaConf 3.1.7

Currently, this works when get/setting individual keys:

from dynaconf import Dynaconf

settings = Dynaconf()
settings.set('FOO.BAR', 'baz', dotted_lookup=False)
print(settings.get('FOO.BAR', dotted_lookup=False))
# baz

I'm using the 12factorapp technique where I only have a .env file and no settings file. In that I'd like to setup python logging configuration which uses dotted path for dict keys. This is what I have:

.env

MYAPP_LOGGING__version=1
MYAPP_LOGGING__loggers__sqlalchemy.engine__level=DEBUG

main.py

import logging
import logging.config
from dynaconf import Dynaconf

settings = Dynaconf(
    auto_cast=True,
    load_dotenv=True,
    environments=False,
    envvar_prefix="MYAPP",
    nested_separator='__',
    dotted_lookup=False,  # this doesn't work
)

print(settings['LOGGING'])
# {'loggers': {'sqlalchemy': {'engine': {'level': 'DEBUG'}}}, 'version': 1}

logging.config.dictConfig(settings['LOGGING'])
print(logging.getLogger('sqlalchemy.engine').getEffectiveLevel() == logging.DEBUG)
# False

Is there a way to do this currently or is it not supported ?

Thanks for any help :)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions