#23569 closed Bug (fixed)
settings.LOGGING_CONFIG assumes dictConfig()
| Reported by: | Seth Hill | Owned by: | nobody |
|---|---|---|---|
| Component: | Core (Other) | Version: | 1.7 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
It seems that if you set the LOGGING_CONFIG settings var to fileConfig(), django breaks.
It seems like the intention here is to create a set of default logging configurations, and then allow the user to override them. That seems like a good idea, except the DEFAULT_LOGGING variable is a dict, which is passed into the user-defined logging_config_func. So it seems like only dictConfig() is allowed.
The trouble spot seems to be in django/utils/log.py:76:
if logging_config:
# First find the logging configuration function ...
logging_config_func = import_string(logging_config)
logging_config_func(DEFAULT_LOGGING)
# ... then invoke it with the logging settings
if logging_settings:
logging_config_func(logging_settings)
I think this should be something like:
if logging_config:
# First find the logging configuration function ...
logging_config_func = import_string(logging_config)
dictConfig(DEFAULT_LOGGING)
# ... then invoke it with the logging settings
if logging_settings:
logging_config_func(logging_settings)
In my case, I have defined
LOGGING_CONFIG = 'logging.config.fileConfig' LOGGING = '/path/to/ini_file'
Which results in an obscure ConfigParser.NoSectionError: No section: 'formatters', as the fileConfig() is trying to use a ConfigParser to read a dictionary.
Change History (5)
comment:1 by , 11 years ago
| Needs tests: | set |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
comment:2 by , 11 years ago
I made a pull request for it here: https://github.com/django/django/pull/3288
comment:3 by , 11 years ago
| Needs tests: | unset |
|---|
comment:4 by , 11 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
This analysis seems correct to me.