Django doesn't require a string for log level. The contents of the LOGGING
setting are passed directly to the callable in LOGGING_CONFIG, which
defaults to logging.config.dictConfig, which takes numbers.

Demo:

In [1]: import logging

In [2]: from django.conf import settings

In [3]: import django

In [4]: settings.configure(LOGGING={"version": 1, "level":
logging.CRITICAL})

In [5]: django.setup()

If there are some misleading docs, we could correct those, but I can't spot
anything in the configuring logging page (
https://docs.djangoproject.com/en/4.0/topics/logging/#configuring-logging )
that says "level must be a string".

On Tue, Apr 5, 2022 at 3:28 AM Jason Johns <jjohns98...@gmail.com> wrote:

> How would this work with secret stores like hashicorp vault, aws secrets
> manager?  Or even via environment variables?  This approach would work if
> you define the logging level in your configuration, but not so friendly for
> other approaches.
>
> On Monday, April 4, 2022 at 9:26:02 PM UTC-4 Dan Swain wrote:
>
>> The current Django LOGGING setup requires a string for the "level".  This
>> is not intuitive since the Python logging module defines logging.DEBUG,
>> logging.INFO, etc.  I think one should be able to configure the logging
>> level using {  'level': logging.DEBUG  } rather than being required to use
>> {  'level': 'DEBUG'  }.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/9e295cb2-e009-4a0a-b506-cb1ebec77761n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-developers/9e295cb2-e009-4a0a-b506-cb1ebec77761n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAMyDDM1DCpF3Cz7KpmgnEPWGAZfz8cK1FmRjAY5isw6xM6ocWg%40mail.gmail.com.
  • Con... Dan Swain
    • ... Jason Johns
      • ... 'Adam Johnson' via Django developers (Contributions to Django itself)
    • ... Curtis Maloney
    • ... Kshitij Gavhane

Reply via email to