Ticket #24361: dj-doc-logging.patch

File dj-doc-logging.patch, 2.9 KB (added by Vlada Macek, 10 years ago)
  • docs/topics/logging.txt

    diff --git a/docs/topics/logging.txt b/docs/topics/logging.txt
    index 9318dbe..e37b8bd 100644
    a b configuration merged with Django's defaults, hence you can decide if you want to  
    219219add to, or replace the existing configuration.
    220220
    221221If the ``disable_existing_loggers`` key in the :setting:`LOGGING` dictConfig is
    222 set to ``True`` (which is the default) the default configuration is completely
    223 overridden. Alternatively you can redefine some or all of the loggers by
    224 setting ``disable_existing_loggers`` to ``False``.
     222set to ``True`` (which is the default) then all loggers from the default
     223configuration will be disabled.  Alternatively you can redefine some or all
     224of the loggers by setting ``disable_existing_loggers`` to ``False``.
     225
     226.. note::
     227    There is a catch in the way the Python Logger class is implemented: Any
     228    *disabled logger* defined by the Django's default logging configuration
     229    is also not propagating events to its parent. If you want to build your
     230    logging configuration from scratch, then it is not enough to set
     231    ``disable_existing_loggers`` to ``True``.  Refer to
     232    :ref:`disabling-logging-configuration` for an example.
    225233
    226234Logging is configured as part of the general Django ``setup()`` function.
    227235Therefore, you can be certain that loggers are always ready for use in your
    use a different configuration process, you can use any other callable  
    390398that takes a single argument. The contents of :setting:`LOGGING` will
    391399be provided as the value of that argument when logging is configured.
    392400
     401.. _disabling-logging-configuration:
     402
    393403Disabling logging configuration
    394404-------------------------------
    395405
    configuration process.  
    405415    calls, falling back to whatever default logging behavior is
    406416    defined.
    407417
     418Here's an example how to make the logging system under Django to log
     419everything to console without having the disabled (but still existing)
     420loggers to swallow events.  You may want to activate this when using the
     421``runserver``::
     422
     423    LOGGING_CONFIG = None
     424    LOGGING = {
     425        'version': 1,
     426        'handlers': {
     427            'console': {
     428                'level': os.getenv('LOGLEVEL', 'INFO'),
     429                'class': 'logging.StreamHandler',
     430                'formatter': 'debugging',
     431            },
     432        },
     433        'formatters': {
     434            'debugging': {
     435                'format': '%(name)s %(levelname)s %(module)s:%(lineno)s: %(message)s'
     436            },
     437        },
     438        # A catch-all root logger.
     439        'root': {
     440            'handlers': ['console'],
     441            'level': 'DEBUG',
     442        },
     443    }
     444
     445    import logging.config
     446    logging.config.dictConfig(LOGGING)
     447
     448By setting the ``LOGLEVEL=DEBUG`` environment variable, you'll see the
     449database queries among other stuff.
     450
     451
    408452Django's logging extensions
    409453===========================
    410454
Back to Top