Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #14861 -- Added an admonition about the potential for circular …

…imports with custom logging handlers (which produces an extremely confusing error message) to the logging docs. Thanks to donspaulding for the report and adamv for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15449 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 66312066a01af1325280b07d8e6942b03a46d650 1 parent f80e997
authored February 07, 2011

Showing 1 changed file with 30 additions and 0 deletions. Show diff stats Hide diff stats

  1. 30  docs/topics/logging.txt
30  docs/topics/logging.txt
@@ -349,6 +349,36 @@ This logging configuration does the following things:
349 349
           printed to the console; ``ERROR`` and ``CRITICAL``
350 350
           messages will also be output via e-mail.
351 351
 
  352
+.. admonition:: Custom handlers and circular imports
  353
+
  354
+    If your ``settings.py`` specifies a custom handler class and the file
  355
+    defining that class also imports ``settings.py`` a circular import will
  356
+    occur.
  357
+
  358
+    For example, if ``settings.py`` contains the following config for
  359
+    :setting:`LOGGING`::
  360
+
  361
+        LOGGING = {
  362
+          'version': 1,
  363
+          'handlers': {
  364
+            'custom_handler': {
  365
+              'level': 'INFO',
  366
+              'class': 'myproject.logconfig.MyHandler',
  367
+            }
  368
+          }
  369
+        }
  370
+
  371
+    and ``myproject/logconfig.py`` has the following line before the
  372
+    ``MyHandler`` definition::
  373
+
  374
+        from django.conf import settings
  375
+
  376
+    then the ``dictconfig`` module will raise an exception like the following::
  377
+
  378
+        ValueError: Unable to configure handler 'custom_handler':
  379
+        Unable to configure handler 'custom_handler':
  380
+        'module' object has no attribute 'logconfig'
  381
+
352 382
 .. _formatter documentation: http://docs.python.org/library/logging.html#formatter-objects
353 383
 
354 384
 Custom logging configuration

0 notes on commit 6631206

Please sign in to comment.
Something went wrong with that request. Please try again.