4

I am setting up logging in Django, but for some reason I see no logs appear. Django uses Python's logging module (I use Python 2.7).

Is there a way I can see the currently configured logging setup, something like a logging.getConfigDict() or so?

RemcoGerlich
  • 30,470
  • 6
  • 61
  • 79
  • 1
    you can see your logging config via the `LOGGING` settings in django, you can use the Django Debug Toolbar to see the value. Or with the `./manage.py shell`, you can do `from django.conf import settings;print(settings.LOGGING)`. – damio Aug 03 '16 at 13:01
  • see also django default behavior, if DEBUG is False, it's not gonna log to the console: https://docs.djangoproject.com/en/1.9/topics/logging/#django-s-default-logging-configuration – damio Aug 03 '16 at 13:03
  • It turned out that I was using another settings file... but I still wonder how I can ask the standard library's logging module what its current settings are. Django has its own logging settings as well, what is in LOGGING is not necessarily all that is configured in logging. – RemcoGerlich Aug 03 '16 at 13:14
  • Check out `logging.root.manager` as suggested [here](https://stackoverflow.com/a/62742295). – djvg Dec 12 '22 at 12:34
  • @damio `settings.LOGGING` does not represent the complete logging configuration. As can be seen [here](https://github.com/django/django/blob/db7bb3b64e469fbb5c79e7b5b2fcb890434aa60f/django/utils/log.py#L67), and as mentioned in the [docs](https://docs.djangoproject.com/en/4.1/topics/logging/#configuring-logging), Django first applies its default logging configuration, then updates that with `settings.LOGGING`. – djvg Dec 12 '22 at 12:40

1 Answers1

4

There's the logging_tree module for that:

pip install logging_tree

and then (via ./manage.py shell)

import logging_tree
logging_tree.printout()

More infos: http://rhodesmill.org/brandon/2012/logging_tree/

damio
  • 6,041
  • 3
  • 39
  • 58