Sophie

Sophie

distrib > Fedora > 20 > i386 > by-pkgid > 422242acff54b9373d7d4b7f73232ce1 > files > 811

python3-django-doc-1.6.7-1.fc20.noarch.rpm


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Logging &mdash; Django 1.6.7 documentation</title>
    
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '1.6.7',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="top" title="Django 1.6.7 documentation" href="../index.html" />
    <link rel="up" title="Using Django" href="index.html" />
    <link rel="next" title="Pagination" href="pagination.html" />
    <link rel="prev" title="The “local flavor” add-ons" href="localflavor.html" />



 
<script type="text/javascript" src="../templatebuiltins.js"></script>
<script type="text/javascript">
(function($) {
    if (!django_template_builtins) {
       // templatebuiltins.js missing, do nothing.
       return;
    }
    $(document).ready(function() {
        // Hyperlink Django template tags and filters
        var base = "../ref/templates/builtins.html";
        if (base == "#") {
            // Special case for builtins.html itself
            base = "";
        }
        // Tags are keywords, class '.k'
        $("div.highlight\\-html\\+django span.k").each(function(i, elem) {
             var tagname = $(elem).text();
             if ($.inArray(tagname, django_template_builtins.ttags) != -1) {
                 var fragment = tagname.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + tagname + "</a>");
             }
        });
        // Filters are functions, class '.nf'
        $("div.highlight\\-html\\+django span.nf").each(function(i, elem) {
             var filtername = $(elem).text();
             if ($.inArray(filtername, django_template_builtins.tfilters) != -1) {
                 var fragment = filtername.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + filtername + "</a>");
             }
        });
    });
})(jQuery);
</script>


  </head>
  <body>

    <div class="document">
  <div id="custom-doc" class="yui-t6">
    <div id="hd">
      <h1><a href="../index.html">Django 1.6.7 documentation</a></h1>
      <div id="global-nav">
        <a title="Home page" href="../index.html">Home</a>  |
        <a title="Table of contents" href="../contents.html">Table of contents</a>  |
        <a title="Global index" href="../genindex.html">Index</a>  |
        <a title="Module index" href="../py-modindex.html">Modules</a>
      </div>
      <div class="nav">
    &laquo; <a href="localflavor.html" title="The &amp;#8220;local flavor&amp;#8221; add-ons">previous</a> 
     |
    <a href="index.html" title="Using Django" accesskey="U">up</a>
   |
    <a href="pagination.html" title="Pagination">next</a> &raquo;</div>
    </div>
    
    <div id="bd">
      <div id="yui-main">
        <div class="yui-b">
          <div class="yui-g" id="topics-logging">
            
  <div class="section" id="s-module-django.utils.log">
<span id="s-logging"></span><span id="module-django.utils.log"></span><span id="logging"></span><h1>Logging<a class="headerlink" href="#module-django.utils.log" title="Permalink to this headline">¶</a></h1>
<div class="section" id="s-a-quick-logging-primer">
<span id="a-quick-logging-primer"></span><h2>A quick logging primer<a class="headerlink" href="#a-quick-logging-primer" title="Permalink to this headline">¶</a></h2>
<p>Django uses Python&#8217;s builtin <tt class="xref py py-mod docutils literal"><span class="pre">logging</span></tt> module to perform system logging.
The usage of this module is discussed in detail in Python&#8217;s own documentation.
However, if you&#8217;ve never used Python&#8217;s logging framework (or even if you have),
here&#8217;s a quick primer.</p>
<div class="section" id="s-the-cast-of-players">
<span id="the-cast-of-players"></span><h3>The cast of players<a class="headerlink" href="#the-cast-of-players" title="Permalink to this headline">¶</a></h3>
<p>A Python logging configuration consists of four parts:</p>
<ul class="simple">
<li><a class="reference internal" href="#topic-logging-parts-loggers"><em>Loggers</em></a></li>
<li><a class="reference internal" href="#topic-logging-parts-handlers"><em>Handlers</em></a></li>
<li><a class="reference internal" href="#topic-logging-parts-filters"><em>Filters</em></a></li>
<li><a class="reference internal" href="#topic-logging-parts-formatters"><em>Formatters</em></a></li>
</ul>
<div class="section" id="s-loggers">
<span id="s-topic-logging-parts-loggers"></span><span id="loggers"></span><span id="topic-logging-parts-loggers"></span><h4>Loggers<a class="headerlink" href="#loggers" title="Permalink to this headline">¶</a></h4>
<p>A logger is the entry point into the logging system. Each logger is
a named bucket to which messages can be written for processing.</p>
<p>A logger is configured to have a <em>log level</em>. This log level describes
the severity of the messages that the logger will handle. Python
defines the following log levels:</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">DEBUG</span></tt>: Low level system information for debugging purposes</li>
<li><tt class="docutils literal"><span class="pre">INFO</span></tt>: General system information</li>
<li><tt class="docutils literal"><span class="pre">WARNING</span></tt>: Information describing a minor problem that has
occurred.</li>
<li><tt class="docutils literal"><span class="pre">ERROR</span></tt>: Information describing a major problem that has
occurred.</li>
<li><tt class="docutils literal"><span class="pre">CRITICAL</span></tt>: Information describing a critical problem that has
occurred.</li>
</ul>
<p>Each message that is written to the logger is a <em>Log Record</em>. Each log
record also has a <em>log level</em> indicating the severity of that specific
message. A log record can also contain useful metadata that describes
the event that is being logged. This can include details such as a
stack trace or an error code.</p>
<p>When a message is given to the logger, the log level of the message is
compared to the log level of the logger. If the log level of the
message meets or exceeds the log level of the logger itself, the
message will undergo further processing. If it doesn&#8217;t, the message
will be ignored.</p>
<p>Once a logger has determined that a message needs to be processed,
it is passed to a <em>Handler</em>.</p>
</div>
<div class="section" id="s-handlers">
<span id="s-topic-logging-parts-handlers"></span><span id="handlers"></span><span id="topic-logging-parts-handlers"></span><h4>Handlers<a class="headerlink" href="#handlers" title="Permalink to this headline">¶</a></h4>
<p>The handler is the engine that determines what happens to each message
in a logger. It describes a particular logging behavior, such as
writing a message to the screen, to a file, or to a network socket.</p>
<p>Like loggers, handlers also have a log level. If the log level of a
log record doesn&#8217;t meet or exceed the level of the handler, the
handler will ignore the message.</p>
<p>A logger can have multiple handlers, and each handler can have a
different log level. In this way, it is possible to provide different
forms of notification depending on the importance of a message. For
example, you could install one handler that forwards <tt class="docutils literal"><span class="pre">ERROR</span></tt> and
<tt class="docutils literal"><span class="pre">CRITICAL</span></tt> messages to a paging service, while a second handler
logs all messages (including <tt class="docutils literal"><span class="pre">ERROR</span></tt> and <tt class="docutils literal"><span class="pre">CRITICAL</span></tt> messages) to a
file for later analysis.</p>
</div>
<div class="section" id="s-filters">
<span id="s-topic-logging-parts-filters"></span><span id="filters"></span><span id="topic-logging-parts-filters"></span><h4>Filters<a class="headerlink" href="#filters" title="Permalink to this headline">¶</a></h4>
<p>A filter is used to provide additional control over which log records
are passed from logger to handler.</p>
<p>By default, any log message that meets log level requirements will be
handled. However, by installing a filter, you can place additional
criteria on the logging process. For example, you could install a
filter that only allows <tt class="docutils literal"><span class="pre">ERROR</span></tt> messages from a particular source to
be emitted.</p>
<p>Filters can also be used to modify the logging record prior to being
emitted. For example, you could write a filter that downgrades
<tt class="docutils literal"><span class="pre">ERROR</span></tt> log records to <tt class="docutils literal"><span class="pre">WARNING</span></tt> records if a particular set of
criteria are met.</p>
<p>Filters can be installed on loggers or on handlers; multiple filters
can be used in a chain to perform multiple filtering actions.</p>
</div>
<div class="section" id="s-formatters">
<span id="s-topic-logging-parts-formatters"></span><span id="formatters"></span><span id="topic-logging-parts-formatters"></span><h4>Formatters<a class="headerlink" href="#formatters" title="Permalink to this headline">¶</a></h4>
<p>Ultimately, a log record needs to be rendered as text. Formatters
describe the exact format of that text. A formatter usually consists
of a Python formatting string; however, you can also write custom
formatters to implement specific formatting behavior.</p>
</div>
</div>
</div>
<div class="section" id="s-using-logging">
<span id="using-logging"></span><h2>Using logging<a class="headerlink" href="#using-logging" title="Permalink to this headline">¶</a></h2>
<p>Once you have configured your loggers, handlers, filters and
formatters, you need to place logging calls into your code. Using the
logging framework is very simple. Here&#8217;s an example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># import the logging library</span>
<span class="kn">import</span> <span class="nn">logging</span>

<span class="c"># Get an instance of a logger</span>
<span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="n">__name__</span><span class="p">)</span>

<span class="k">def</span> <span class="nf">my_view</span><span class="p">(</span><span class="n">request</span><span class="p">,</span> <span class="n">arg1</span><span class="p">,</span> <span class="n">arg</span><span class="p">):</span>
    <span class="o">...</span>
    <span class="k">if</span> <span class="n">bad_mojo</span><span class="p">:</span>
        <span class="c"># Log an error message</span>
        <span class="n">logger</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s">&#39;Something went wrong!&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>And that&#8217;s it! Every time the <tt class="docutils literal"><span class="pre">bad_mojo</span></tt> condition is activated, an
error log record will be written.</p>
<div class="section" id="s-naming-loggers">
<span id="naming-loggers"></span><h3>Naming loggers<a class="headerlink" href="#naming-loggers" title="Permalink to this headline">¶</a></h3>
<p>The call to <tt class="xref py py-func docutils literal"><span class="pre">logging.getLogger()</span></tt> obtains (creating, if
necessary) an instance of a logger. The logger instance is identified
by a name. This name is used to identify the logger for configuration
purposes.</p>
<p>By convention, the logger name is usually <tt class="docutils literal"><span class="pre">__name__</span></tt>, the name of
the python module that contains the logger. This allows you to filter
and handle logging calls on a per-module basis. However, if you have
some other way of organizing your logging messages, you can provide
any dot-separated name to identify your logger:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># Get an instance of a specific named logger</span>
<span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s">&#39;project.interesting.stuff&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>The dotted paths of logger names define a hierarchy. The
<tt class="docutils literal"><span class="pre">project.interesting</span></tt> logger is considered to be a parent of the
<tt class="docutils literal"><span class="pre">project.interesting.stuff</span></tt> logger; the <tt class="docutils literal"><span class="pre">project</span></tt> logger
is a parent of the <tt class="docutils literal"><span class="pre">project.interesting</span></tt> logger.</p>
<p>Why is the hierarchy important? Well, because loggers can be set to
<em>propagate</em> their logging calls to their parents. In this way, you can
define a single set of handlers at the root of a logger tree, and
capture all logging calls in the subtree of loggers. A logging handler
defined in the <tt class="docutils literal"><span class="pre">project</span></tt> namespace will catch all logging messages
issued on the <tt class="docutils literal"><span class="pre">project.interesting</span></tt> and
<tt class="docutils literal"><span class="pre">project.interesting.stuff</span></tt> loggers.</p>
<p>This propagation can be controlled on a per-logger basis. If
you don&#8217;t want a particular logger to propagate to its parents, you
can turn off this behavior.</p>
</div>
<div class="section" id="s-making-logging-calls">
<span id="making-logging-calls"></span><h3>Making logging calls<a class="headerlink" href="#making-logging-calls" title="Permalink to this headline">¶</a></h3>
<p>The logger instance contains an entry method for each of the default
log levels:</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">logger.critical()</span></tt></li>
<li><tt class="docutils literal"><span class="pre">logger.error()</span></tt></li>
<li><tt class="docutils literal"><span class="pre">logger.warning()</span></tt></li>
<li><tt class="docutils literal"><span class="pre">logger.info()</span></tt></li>
<li><tt class="docutils literal"><span class="pre">logger.debug()</span></tt></li>
</ul>
<p>There are two other logging calls available:</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">logger.log()</span></tt>: Manually emits a logging message with a
specific log level.</li>
<li><tt class="docutils literal"><span class="pre">logger.exception()</span></tt>: Creates an <tt class="docutils literal"><span class="pre">ERROR</span></tt> level logging
message wrapping the current exception stack frame.</li>
</ul>
</div>
</div>
<div class="section" id="s-configuring-logging">
<span id="s-id1"></span><span id="configuring-logging"></span><span id="id1"></span><h2>Configuring logging<a class="headerlink" href="#configuring-logging" title="Permalink to this headline">¶</a></h2>
<p>Of course, it isn&#8217;t enough to just put logging calls into your code.
You also need to configure the loggers, handlers, filters and
formatters to ensure that logging output is output in a useful way.</p>
<p>Python&#8217;s logging library provides several techniques to configure
logging, ranging from a programmatic interface to configuration files.
By default, Django uses the <a class="reference external" href="http://docs.python.org/library/logging.config.html#configuration-dictionary-schema">dictConfig format</a>.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last"><tt class="docutils literal"><span class="pre">logging.dictConfig</span></tt> is a builtin library in Python 2.7. In
order to make this library available for users of earlier Python
versions, Django includes a copy as part of <tt class="docutils literal"><span class="pre">django.utils.log</span></tt>.
If you have Python 2.7 or later, the system native library will be used; if
you have Python 2.6, Django&#8217;s copy will be used.</p>
</div>
<p>In order to configure logging, you use <a class="reference internal" href="../ref/settings.html#std:setting-LOGGING"><tt class="xref std std-setting docutils literal"><span class="pre">LOGGING</span></tt></a> to define a
dictionary of logging settings. These settings describes the loggers,
handlers, filters and formatters that you want in your logging setup,
and the log levels and other properties that you want those components
to have.</p>
<p>Prior to Django 1.5, the <a class="reference internal" href="../ref/settings.html#std:setting-LOGGING"><tt class="xref std std-setting docutils literal"><span class="pre">LOGGING</span></tt></a> setting always overwrote the
<a class="reference internal" href="#default-logging-configuration"><em>default Django logging configuration</em></a>.
From Django 1.5 forward, it is possible to get the project&#8217;s logging
configuration merged with Django&#8217;s defaults, hence you can decide if you want to
add to, or replace the existing configuration.</p>
<p>If the <tt class="docutils literal"><span class="pre">disable_existing_loggers</span></tt> key in the <a class="reference internal" href="../ref/settings.html#std:setting-LOGGING"><tt class="xref std std-setting docutils literal"><span class="pre">LOGGING</span></tt></a> dictConfig is
set to <tt class="docutils literal"><span class="pre">True</span></tt> (which is the default) the default configuration is completely
overridden. Alternatively you can redefine some or all of the loggers by
setting <tt class="docutils literal"><span class="pre">disable_existing_loggers</span></tt> to <tt class="docutils literal"><span class="pre">False</span></tt>.</p>
<p>Logging is configured as soon as settings have been loaded
(either manually using <a class="reference internal" href="settings.html#django.conf.settings.configure" title="django.conf.settings.configure"><tt class="xref py py-func docutils literal"><span class="pre">configure()</span></tt></a> or when at least
one setting is accessed). Since the loading of settings is one of the first
things that Django does, you can be certain that loggers are always ready for
use in your project code.</p>
<div class="section" id="s-examples">
<span id="examples"></span><h3>Examples<a class="headerlink" href="#examples" title="Permalink to this headline">¶</a></h3>
<p>The full documentation for <a class="reference external" href="http://docs.python.org/library/logging.config.html#configuration-dictionary-schema">dictConfig format</a> is the best source of
information about logging configuration dictionaries. However, to give
you a taste of what is possible, here are a couple examples.</p>
<p>First, here&#8217;s a simple configuration which writes all request logging from the
<a class="reference internal" href="#django-request-logger"><em>django.request</em></a> logger to a local file:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">LOGGING</span> <span class="o">=</span> <span class="p">{</span>
    <span class="s">&#39;version&#39;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
    <span class="s">&#39;disable_existing_loggers&#39;</span><span class="p">:</span> <span class="bp">False</span><span class="p">,</span>
    <span class="s">&#39;handlers&#39;</span><span class="p">:</span> <span class="p">{</span>
        <span class="s">&#39;file&#39;</span><span class="p">:</span> <span class="p">{</span>
            <span class="s">&#39;level&#39;</span><span class="p">:</span> <span class="s">&#39;DEBUG&#39;</span><span class="p">,</span>
            <span class="s">&#39;class&#39;</span><span class="p">:</span> <span class="s">&#39;logging.FileHandler&#39;</span><span class="p">,</span>
            <span class="s">&#39;filename&#39;</span><span class="p">:</span> <span class="s">&#39;/path/to/django/debug.log&#39;</span><span class="p">,</span>
        <span class="p">},</span>
    <span class="p">},</span>
    <span class="s">&#39;loggers&#39;</span><span class="p">:</span> <span class="p">{</span>
        <span class="s">&#39;django.request&#39;</span><span class="p">:</span> <span class="p">{</span>
            <span class="s">&#39;handlers&#39;</span><span class="p">:</span> <span class="p">[</span><span class="s">&#39;file&#39;</span><span class="p">],</span>
            <span class="s">&#39;level&#39;</span><span class="p">:</span> <span class="s">&#39;DEBUG&#39;</span><span class="p">,</span>
            <span class="s">&#39;propagate&#39;</span><span class="p">:</span> <span class="bp">True</span><span class="p">,</span>
        <span class="p">},</span>
    <span class="p">},</span>
<span class="p">}</span>
</pre></div>
</div>
<p>If you use this example, be sure to change the <tt class="docutils literal"><span class="pre">'filename'</span></tt> path to a
location that&#8217;s writable by the user that&#8217;s running the Django application.</p>
<p>Second, here&#8217;s an example of a fairly complex logging setup, configured using
<tt class="xref py py-func docutils literal"><span class="pre">logging.config.dictConfig()</span></tt>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">LOGGING</span> <span class="o">=</span> <span class="p">{</span>
    <span class="s">&#39;version&#39;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
    <span class="s">&#39;disable_existing_loggers&#39;</span><span class="p">:</span> <span class="bp">True</span><span class="p">,</span>
    <span class="s">&#39;formatters&#39;</span><span class="p">:</span> <span class="p">{</span>
        <span class="s">&#39;verbose&#39;</span><span class="p">:</span> <span class="p">{</span>
            <span class="s">&#39;format&#39;</span><span class="p">:</span> <span class="s">&#39;</span><span class="si">%(levelname)s</span><span class="s"> </span><span class="si">%(asctime)s</span><span class="s"> </span><span class="si">%(module)s</span><span class="s"> </span><span class="si">%(process)d</span><span class="s"> </span><span class="si">%(thread)d</span><span class="s"> </span><span class="si">%(message)s</span><span class="s">&#39;</span>
        <span class="p">},</span>
        <span class="s">&#39;simple&#39;</span><span class="p">:</span> <span class="p">{</span>
            <span class="s">&#39;format&#39;</span><span class="p">:</span> <span class="s">&#39;</span><span class="si">%(levelname)s</span><span class="s"> </span><span class="si">%(message)s</span><span class="s">&#39;</span>
        <span class="p">},</span>
    <span class="p">},</span>
    <span class="s">&#39;filters&#39;</span><span class="p">:</span> <span class="p">{</span>
        <span class="s">&#39;special&#39;</span><span class="p">:</span> <span class="p">{</span>
            <span class="s">&#39;()&#39;</span><span class="p">:</span> <span class="s">&#39;project.logging.SpecialFilter&#39;</span><span class="p">,</span>
            <span class="s">&#39;foo&#39;</span><span class="p">:</span> <span class="s">&#39;bar&#39;</span><span class="p">,</span>
        <span class="p">}</span>
    <span class="p">},</span>
    <span class="s">&#39;handlers&#39;</span><span class="p">:</span> <span class="p">{</span>
        <span class="s">&#39;null&#39;</span><span class="p">:</span> <span class="p">{</span>
            <span class="s">&#39;level&#39;</span><span class="p">:</span> <span class="s">&#39;DEBUG&#39;</span><span class="p">,</span>
            <span class="s">&#39;class&#39;</span><span class="p">:</span> <span class="s">&#39;django.utils.log.NullHandler&#39;</span><span class="p">,</span>
        <span class="p">},</span>
        <span class="s">&#39;console&#39;</span><span class="p">:{</span>
            <span class="s">&#39;level&#39;</span><span class="p">:</span> <span class="s">&#39;DEBUG&#39;</span><span class="p">,</span>
            <span class="s">&#39;class&#39;</span><span class="p">:</span> <span class="s">&#39;logging.StreamHandler&#39;</span><span class="p">,</span>
            <span class="s">&#39;formatter&#39;</span><span class="p">:</span> <span class="s">&#39;simple&#39;</span>
        <span class="p">},</span>
        <span class="s">&#39;mail_admins&#39;</span><span class="p">:</span> <span class="p">{</span>
            <span class="s">&#39;level&#39;</span><span class="p">:</span> <span class="s">&#39;ERROR&#39;</span><span class="p">,</span>
            <span class="s">&#39;class&#39;</span><span class="p">:</span> <span class="s">&#39;django.utils.log.AdminEmailHandler&#39;</span><span class="p">,</span>
            <span class="s">&#39;filters&#39;</span><span class="p">:</span> <span class="p">[</span><span class="s">&#39;special&#39;</span><span class="p">]</span>
        <span class="p">}</span>
    <span class="p">},</span>
    <span class="s">&#39;loggers&#39;</span><span class="p">:</span> <span class="p">{</span>
        <span class="s">&#39;django&#39;</span><span class="p">:</span> <span class="p">{</span>
            <span class="s">&#39;handlers&#39;</span><span class="p">:</span> <span class="p">[</span><span class="s">&#39;null&#39;</span><span class="p">],</span>
            <span class="s">&#39;propagate&#39;</span><span class="p">:</span> <span class="bp">True</span><span class="p">,</span>
            <span class="s">&#39;level&#39;</span><span class="p">:</span> <span class="s">&#39;INFO&#39;</span><span class="p">,</span>
        <span class="p">},</span>
        <span class="s">&#39;django.request&#39;</span><span class="p">:</span> <span class="p">{</span>
            <span class="s">&#39;handlers&#39;</span><span class="p">:</span> <span class="p">[</span><span class="s">&#39;mail_admins&#39;</span><span class="p">],</span>
            <span class="s">&#39;level&#39;</span><span class="p">:</span> <span class="s">&#39;ERROR&#39;</span><span class="p">,</span>
            <span class="s">&#39;propagate&#39;</span><span class="p">:</span> <span class="bp">False</span><span class="p">,</span>
        <span class="p">},</span>
        <span class="s">&#39;myproject.custom&#39;</span><span class="p">:</span> <span class="p">{</span>
            <span class="s">&#39;handlers&#39;</span><span class="p">:</span> <span class="p">[</span><span class="s">&#39;console&#39;</span><span class="p">,</span> <span class="s">&#39;mail_admins&#39;</span><span class="p">],</span>
            <span class="s">&#39;level&#39;</span><span class="p">:</span> <span class="s">&#39;INFO&#39;</span><span class="p">,</span>
            <span class="s">&#39;filters&#39;</span><span class="p">:</span> <span class="p">[</span><span class="s">&#39;special&#39;</span><span class="p">]</span>
        <span class="p">}</span>
    <span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<p>This logging configuration does the following things:</p>
<ul>
<li><p class="first">Identifies the configuration as being in &#8216;dictConfig version 1&#8217;
format. At present, this is the only dictConfig format version.</p>
</li>
<li><p class="first">Disables all existing logging configurations.</p>
</li>
<li><p class="first">Defines two formatters:</p>
<ul>
<li><p class="first"><tt class="docutils literal"><span class="pre">simple</span></tt>, that just outputs the log level name (e.g.,
<tt class="docutils literal"><span class="pre">DEBUG</span></tt>) and the log message.</p>
<p>The <tt class="docutils literal"><span class="pre">format</span></tt> string is a normal Python formatting string
describing the details that are to be output on each logging
line. The full list of detail that can be output can be
found in the <a class="reference external" href="http://docs.python.org/library/logging.html#formatter-objects">formatter documentation</a>.</p>
</li>
<li><p class="first"><tt class="docutils literal"><span class="pre">verbose</span></tt>, that outputs the log level name, the log
message, plus the time, process, thread and module that
generate the log message.</p>
</li>
</ul>
</li>
<li><p class="first">Defines one filter &#8211; <tt class="docutils literal"><span class="pre">project.logging.SpecialFilter</span></tt>,
using the alias <tt class="docutils literal"><span class="pre">special</span></tt>. If this filter required additional
arguments at time of construction, they can be provided as
additional keys in the filter configuration dictionary. In this
case, the argument <tt class="docutils literal"><span class="pre">foo</span></tt> will be given a value of <tt class="docutils literal"><span class="pre">bar</span></tt> when
instantiating the <tt class="docutils literal"><span class="pre">SpecialFilter</span></tt>.</p>
</li>
<li><p class="first">Defines three handlers:</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">null</span></tt>, a NullHandler, which will pass any <tt class="docutils literal"><span class="pre">DEBUG</span></tt> (or
higher) message to <tt class="docutils literal"><span class="pre">/dev/null</span></tt>.</li>
<li><tt class="docutils literal"><span class="pre">console</span></tt>, a StreamHandler, which will print any <tt class="docutils literal"><span class="pre">DEBUG</span></tt>
(or higher) message to stderr. This handler uses the <tt class="docutils literal"><span class="pre">simple</span></tt> output
format.</li>
<li><tt class="docutils literal"><span class="pre">mail_admins</span></tt>, an AdminEmailHandler, which will email any
<tt class="docutils literal"><span class="pre">ERROR</span></tt> (or higher) message to the site admins. This handler uses
the <tt class="docutils literal"><span class="pre">special</span></tt> filter.</li>
</ul>
</li>
<li><p class="first">Configures three loggers:</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">django</span></tt>, which passes all messages at <tt class="docutils literal"><span class="pre">INFO</span></tt> or higher
to the <tt class="docutils literal"><span class="pre">null</span></tt> handler.</li>
<li><tt class="docutils literal"><span class="pre">django.request</span></tt>, which passes all <tt class="docutils literal"><span class="pre">ERROR</span></tt> messages to
the <tt class="docutils literal"><span class="pre">mail_admins</span></tt> handler. In addition, this logger is
marked to <em>not</em> propagate messages. This means that log
messages written to <tt class="docutils literal"><span class="pre">django.request</span></tt> will not be handled
by the <tt class="docutils literal"><span class="pre">django</span></tt> logger.</li>
<li><tt class="docutils literal"><span class="pre">myproject.custom</span></tt>, which passes all messages at <tt class="docutils literal"><span class="pre">INFO</span></tt>
or higher that also pass the <tt class="docutils literal"><span class="pre">special</span></tt> filter to two
handlers &#8211; the <tt class="docutils literal"><span class="pre">console</span></tt>, and <tt class="docutils literal"><span class="pre">mail_admins</span></tt>. This
means that all <tt class="docutils literal"><span class="pre">INFO</span></tt> level messages (or higher) will be
printed to the console; <tt class="docutils literal"><span class="pre">ERROR</span></tt> and <tt class="docutils literal"><span class="pre">CRITICAL</span></tt>
messages will also be output via email.</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="s-custom-logging-configuration">
<span id="custom-logging-configuration"></span><h3>Custom logging configuration<a class="headerlink" href="#custom-logging-configuration" title="Permalink to this headline">¶</a></h3>
<p>If you don&#8217;t want to use Python&#8217;s dictConfig format to configure your
logger, you can specify your own configuration scheme.</p>
<p>The <a class="reference internal" href="../ref/settings.html#std:setting-LOGGING_CONFIG"><tt class="xref std std-setting docutils literal"><span class="pre">LOGGING_CONFIG</span></tt></a> setting defines the callable that will
be used to configure Django&#8217;s loggers. By default, it points at
Python&#8217;s <tt class="xref py py-func docutils literal"><span class="pre">logging.config.dictConfig()</span></tt> function. However, if you want to
use a different configuration process, you can use any other callable
that takes a single argument. The contents of <a class="reference internal" href="../ref/settings.html#std:setting-LOGGING"><tt class="xref std std-setting docutils literal"><span class="pre">LOGGING</span></tt></a> will
be provided as the value of that argument when logging is configured.</p>
</div>
<div class="section" id="s-disabling-logging-configuration">
<span id="disabling-logging-configuration"></span><h3>Disabling logging configuration<a class="headerlink" href="#disabling-logging-configuration" title="Permalink to this headline">¶</a></h3>
<p>If you don&#8217;t want to configure logging at all (or you want to manually
configure logging using your own approach), you can set
<a class="reference internal" href="../ref/settings.html#std:setting-LOGGING_CONFIG"><tt class="xref std std-setting docutils literal"><span class="pre">LOGGING_CONFIG</span></tt></a> to <tt class="docutils literal"><span class="pre">None</span></tt>. This will disable the
configuration process.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Setting <a class="reference internal" href="../ref/settings.html#std:setting-LOGGING_CONFIG"><tt class="xref std std-setting docutils literal"><span class="pre">LOGGING_CONFIG</span></tt></a> to <tt class="docutils literal"><span class="pre">None</span></tt> only means that the
configuration process is disabled, not logging itself. If you
disable the configuration process, Django will still make logging
calls, falling back to whatever default logging behavior is
defined.</p>
</div>
</div>
</div>
<div class="section" id="s-django-s-logging-extensions">
<span id="django-s-logging-extensions"></span><h2>Django&#8217;s logging extensions<a class="headerlink" href="#django-s-logging-extensions" title="Permalink to this headline">¶</a></h2>
<p>Django provides a number of utilities to handle the unique
requirements of logging in Web server environment.</p>
<div class="section" id="s-id2">
<span id="id2"></span><h3>Loggers<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h3>
<p>Django provides four built-in loggers.</p>
<div class="section" id="s-django">
<span id="django"></span><h4><tt class="docutils literal"><span class="pre">django</span></tt><a class="headerlink" href="#django" title="Permalink to this headline">¶</a></h4>
<p><tt class="docutils literal"><span class="pre">django</span></tt> is the catch-all logger. No messages are posted directly to
this logger.</p>
</div>
<div class="section" id="s-django-request">
<span id="s-django-request-logger"></span><span id="django-request"></span><span id="django-request-logger"></span><h4><tt class="docutils literal"><span class="pre">django.request</span></tt><a class="headerlink" href="#django-request" title="Permalink to this headline">¶</a></h4>
<p>Log messages related to the handling of requests. 5XX responses are
raised as <tt class="docutils literal"><span class="pre">ERROR</span></tt> messages; 4XX responses are raised as <tt class="docutils literal"><span class="pre">WARNING</span></tt>
messages.</p>
<p>Messages to this logger have the following extra context:</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">status_code</span></tt>: The HTTP response code associated with the
request.</li>
<li><tt class="docutils literal"><span class="pre">request</span></tt>: The request object that generated the logging
message.</li>
</ul>
</div>
<div class="section" id="s-django-db-backends">
<span id="django-db-backends"></span><h4><tt class="docutils literal"><span class="pre">django.db.backends</span></tt><a class="headerlink" href="#django-db-backends" title="Permalink to this headline">¶</a></h4>
<p>Messages relating to the interaction of code with the database. For example,
every application-level SQL statement executed by a request is logged at the
<tt class="docutils literal"><span class="pre">DEBUG</span></tt> level to this logger.</p>
<p>Messages to this logger have the following extra context:</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">duration</span></tt>: The time taken to execute the SQL statement.</li>
<li><tt class="docutils literal"><span class="pre">sql</span></tt>: The SQL statement that was executed.</li>
<li><tt class="docutils literal"><span class="pre">params</span></tt>: The parameters that were used in the SQL call.</li>
</ul>
<p>For performance reasons, SQL logging is only enabled when
<tt class="docutils literal"><span class="pre">settings.DEBUG</span></tt> is set to <tt class="docutils literal"><span class="pre">True</span></tt>, regardless of the logging
level or handlers that are installed.</p>
<p>This logging does not include framework-level initialization (e.g.
<tt class="docutils literal"><span class="pre">SET</span> <span class="pre">TIMEZONE</span></tt>) or transaction management queries (e.g. <tt class="docutils literal"><span class="pre">BEGIN</span></tt>,
<tt class="docutils literal"><span class="pre">COMMIT</span></tt>, and <tt class="docutils literal"><span class="pre">ROLLBACK</span></tt>). Turn on query logging in your database if you
wish the view all database queries.</p>
</div>
<div class="section" id="s-django-security">
<span id="django-security"></span><h4><tt class="docutils literal"><span class="pre">django.security.*</span></tt><a class="headerlink" href="#django-security" title="Permalink to this headline">¶</a></h4>
<p>The security loggers will receive messages on any occurrence of
<a class="reference internal" href="../ref/exceptions.html#django.core.exceptions.SuspiciousOperation" title="django.core.exceptions.SuspiciousOperation"><tt class="xref py py-exc docutils literal"><span class="pre">SuspiciousOperation</span></tt></a>. There is a sub-logger for
each sub-type of SuspiciousOperation. The level of the log event depends on
where the exception is handled.  Most occurrences are logged as a warning, while
any <tt class="docutils literal"><span class="pre">SuspiciousOperation</span></tt> that reaches the WSGI handler will be logged as an
error. For example, when an HTTP <tt class="docutils literal"><span class="pre">Host</span></tt> header is included in a request from
a client that does not match <a class="reference internal" href="../ref/settings.html#std:setting-ALLOWED_HOSTS"><tt class="xref std std-setting docutils literal"><span class="pre">ALLOWED_HOSTS</span></tt></a>, Django will return a 400
response, and an error message will be logged to the
<tt class="docutils literal"><span class="pre">django.security.DisallowedHost</span></tt> logger.</p>
<p>Only the parent <tt class="docutils literal"><span class="pre">django.security</span></tt> logger is configured by default, and all
child loggers will propagate to the parent logger. The <tt class="docutils literal"><span class="pre">django.security</span></tt>
logger is configured the same as the <tt class="docutils literal"><span class="pre">django.request</span></tt> logger, and any error
events will be mailed to admins. Requests resulting in a 400 response due to
a <tt class="docutils literal"><span class="pre">SuspiciousOperation</span></tt> will not be logged to the <tt class="docutils literal"><span class="pre">django.request</span></tt> logger,
but only to the <tt class="docutils literal"><span class="pre">django.security</span></tt> logger.</p>
<p>To silence a particular type of SuspiciousOperation, you can override that
specific logger following this example:</p>
<div class="highlight-python"><pre>'loggers': {
    'django.security.DisallowedHost': {
        'handlers': ['null'],
        'propagate': False,
    },</pre>
</div>
</div>
</div>
<div class="section" id="s-id3">
<span id="id3"></span><h3>Handlers<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h3>
<p>Django provides one log handler in addition to those provided by the
Python logging module.</p>
<dl class="class">
<dt id="django.utils.log.AdminEmailHandler">
<em class="property">class </em><tt class="descname">AdminEmailHandler</tt>(<em>include_html=False</em>, <em>email_backend=None</em>)<a class="reference internal" href="../_modules/django/utils/log.html#AdminEmailHandler"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.utils.log.AdminEmailHandler" title="Permalink to this definition">¶</a></dt>
<dd><p>This handler sends an email to the site admins for each log
message it receives.</p>
<p>If the log record contains a <tt class="docutils literal"><span class="pre">request</span></tt> attribute, the full details
of the request will be included in the email.</p>
<p>If the log record contains stack trace information, that stack
trace will be included in the email.</p>
<p>The <tt class="docutils literal"><span class="pre">include_html</span></tt> argument of <tt class="docutils literal"><span class="pre">AdminEmailHandler</span></tt> is used to
control whether the traceback email includes an HTML attachment
containing the full content of the debug Web page that would have been
produced if <a class="reference internal" href="../ref/settings.html#std:setting-DEBUG"><tt class="xref std std-setting docutils literal"><span class="pre">DEBUG</span></tt></a> were <tt class="docutils literal"><span class="pre">True</span></tt>. To set this value in your
configuration, include it in the handler definition for
<tt class="docutils literal"><span class="pre">django.utils.log.AdminEmailHandler</span></tt>, like this:</p>
<div class="highlight-python"><pre>'handlers': {
    'mail_admins': {
        'level': 'ERROR',
        'class': 'django.utils.log.AdminEmailHandler',
        'include_html': True,
    }
},</pre>
</div>
<p>Note that this HTML version of the email contains a full traceback,
with names and values of local variables at each level of the stack, plus
the values of your Django settings. This information is potentially very
sensitive, and you may not want to send it over email. Consider using
something such as <a class="reference external" href="https://pypi.python.org/pypi/sentry">Sentry</a> to get the best of both worlds &#8211; the
rich information of full tracebacks plus the security of <em>not</em> sending the
information over email. You may also explicitly designate certain
sensitive information to be filtered out of error reports &#8211; learn more on
<a class="reference internal" href="../howto/error-reporting.html#filtering-error-reports"><em>Filtering error reports</em></a>.</p>
<div class="versionadded">
<span class="title">New in Django 1.6.</span> </div>
<p>By setting the <tt class="docutils literal"><span class="pre">email_backend</span></tt> argument of <tt class="docutils literal"><span class="pre">AdminEmailHandler</span></tt>, the
<a class="reference internal" href="email.html#topic-email-backends"><em>email backend</em></a> that is being used by the
handler can be overridden, like this:</p>
<div class="highlight-python"><pre>'handlers': {
    'mail_admins': {
        'level': 'ERROR',
        'class': 'django.utils.log.AdminEmailHandler',
        'email_backend': 'django.core.mail.backends.filebased.EmailBackend',
    }
},</pre>
</div>
<p>By default, an instance of the email backend specified in
<a class="reference internal" href="../ref/settings.html#std:setting-EMAIL_BACKEND"><tt class="xref std std-setting docutils literal"><span class="pre">EMAIL_BACKEND</span></tt></a> will be used.</p>
</dd></dl>

</div>
<div class="section" id="s-id4">
<span id="id4"></span><h3>Filters<a class="headerlink" href="#id4" title="Permalink to this headline">¶</a></h3>
<p>Django provides two log filters in addition to those provided by the Python
logging module.</p>
<dl class="class">
<dt id="django.utils.log.CallbackFilter">
<em class="property">class </em><tt class="descname">CallbackFilter</tt>(<em>callback</em>)<a class="reference internal" href="../_modules/django/utils/log.html#CallbackFilter"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.utils.log.CallbackFilter" title="Permalink to this definition">¶</a></dt>
<dd><p>This filter accepts a callback function (which should accept a single
argument, the record to be logged), and calls it for each record that passes
through the filter. Handling of that record will not proceed if the callback
returns False.</p>
<p>For instance, to filter out <a class="reference internal" href="../ref/exceptions.html#django.http.UnreadablePostError" title="django.http.UnreadablePostError"><tt class="xref py py-exc docutils literal"><span class="pre">UnreadablePostError</span></tt></a>
(raised when a user cancels an upload) from the admin emails, you would
create a filter function:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">django.http</span> <span class="kn">import</span> <span class="n">UnreadablePostError</span>

<span class="k">def</span> <span class="nf">skip_unreadable_post</span><span class="p">(</span><span class="n">record</span><span class="p">):</span>
    <span class="k">if</span> <span class="n">record</span><span class="o">.</span><span class="n">exc_info</span><span class="p">:</span>
        <span class="n">exc_type</span><span class="p">,</span> <span class="n">exc_value</span> <span class="o">=</span> <span class="n">record</span><span class="o">.</span><span class="n">exc_info</span><span class="p">[:</span><span class="mi">2</span><span class="p">]</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">exc_value</span><span class="p">,</span> <span class="n">UnreadablePostError</span><span class="p">):</span>
            <span class="k">return</span> <span class="bp">False</span>
    <span class="k">return</span> <span class="bp">True</span>
</pre></div>
</div>
<p>and then add it to your logging config:</p>
<div class="highlight-python"><pre>'filters': {
    'skip_unreadable_posts': {
        '()': 'django.utils.log.CallbackFilter',
        'callback': skip_unreadable_post,
    }
},
'handlers': {
    'mail_admins': {
        'level': 'ERROR',
        'filters': ['skip_unreadable_posts'],
        'class': 'django.utils.log.AdminEmailHandler'
    }
},</pre>
</div>
</dd></dl>

<dl class="class">
<dt id="django.utils.log.RequireDebugFalse">
<em class="property">class </em><tt class="descname">RequireDebugFalse</tt><a class="reference internal" href="../_modules/django/utils/log.html#RequireDebugFalse"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.utils.log.RequireDebugFalse" title="Permalink to this definition">¶</a></dt>
<dd><p>This filter will only pass on records when settings.DEBUG is False.</p>
<p>This filter is used as follows in the default <a class="reference internal" href="../ref/settings.html#std:setting-LOGGING"><tt class="xref std std-setting docutils literal"><span class="pre">LOGGING</span></tt></a>
configuration to ensure that the <a class="reference internal" href="#django.utils.log.AdminEmailHandler" title="django.utils.log.AdminEmailHandler"><tt class="xref py py-class docutils literal"><span class="pre">AdminEmailHandler</span></tt></a> only sends error
emails to admins when <a class="reference internal" href="../ref/settings.html#std:setting-DEBUG"><tt class="xref std std-setting docutils literal"><span class="pre">DEBUG</span></tt></a> is <tt class="docutils literal"><span class="pre">False</span></tt>:</p>
<div class="highlight-python"><pre>'filters': {
     'require_debug_false': {
         '()': 'django.utils.log.RequireDebugFalse',
     }
 },
 'handlers': {
     'mail_admins': {
         'level': 'ERROR',
         'filters': ['require_debug_false'],
         'class': 'django.utils.log.AdminEmailHandler'
     }
 },</pre>
</div>
</dd></dl>

<dl class="class">
<dt id="django.utils.log.RequireDebugTrue">
<em class="property">class </em><tt class="descname">RequireDebugTrue</tt><a class="reference internal" href="../_modules/django/utils/log.html#RequireDebugTrue"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#django.utils.log.RequireDebugTrue" title="Permalink to this definition">¶</a></dt>
<dd><div class="versionadded">
<span class="title">New in Django 1.5.</span> </div>
<p>This filter is similar to <a class="reference internal" href="#django.utils.log.RequireDebugFalse" title="django.utils.log.RequireDebugFalse"><tt class="xref py py-class docutils literal"><span class="pre">RequireDebugFalse</span></tt></a>, except that records are
passed only when <a class="reference internal" href="../ref/settings.html#std:setting-DEBUG"><tt class="xref std std-setting docutils literal"><span class="pre">DEBUG</span></tt></a> is <tt class="docutils literal"><span class="pre">True</span></tt>.</p>
</dd></dl>

</div>
</div>
<div class="section" id="s-django-s-default-logging-configuration">
<span id="s-default-logging-configuration"></span><span id="django-s-default-logging-configuration"></span><span id="default-logging-configuration"></span><h2>Django&#8217;s default logging configuration<a class="headerlink" href="#django-s-default-logging-configuration" title="Permalink to this headline">¶</a></h2>
<p>By default, Django configures the <tt class="docutils literal"><span class="pre">django.request</span></tt> logger so that all messages
with <tt class="docutils literal"><span class="pre">ERROR</span></tt> or <tt class="docutils literal"><span class="pre">CRITICAL</span></tt> level are sent to <a class="reference internal" href="#django.utils.log.AdminEmailHandler" title="django.utils.log.AdminEmailHandler"><tt class="xref py py-class docutils literal"><span class="pre">AdminEmailHandler</span></tt></a>, as
long as the <a class="reference internal" href="../ref/settings.html#std:setting-DEBUG"><tt class="xref std std-setting docutils literal"><span class="pre">DEBUG</span></tt></a> setting is set to <tt class="docutils literal"><span class="pre">False</span></tt>.</p>
<p>All messages reaching the <tt class="docutils literal"><span class="pre">django</span></tt> catch-all logger when <a class="reference internal" href="../ref/settings.html#std:setting-DEBUG"><tt class="xref std std-setting docutils literal"><span class="pre">DEBUG</span></tt></a> is
<tt class="docutils literal"><span class="pre">True</span></tt> are sent to the console. They are simply discarded (sent to
<tt class="docutils literal"><span class="pre">NullHandler</span></tt>) when <a class="reference internal" href="../ref/settings.html#std:setting-DEBUG"><tt class="xref std std-setting docutils literal"><span class="pre">DEBUG</span></tt></a> is <tt class="docutils literal"><span class="pre">False</span></tt>.</p>
<div class="versionchanged">
<span class="title">Changed in Django 1.5:</span> Before Django 1.5, all messages reaching the <tt class="docutils literal"><span class="pre">django</span></tt> logger were
discarded, regardless of <a class="reference internal" href="../ref/settings.html#std:setting-DEBUG"><tt class="xref std std-setting docutils literal"><span class="pre">DEBUG</span></tt></a>.</div>
<p>See also <a class="reference internal" href="#configuring-logging"><em>Configuring logging</em></a> to learn how you can
complement or replace this default logging configuration.</p>
</div>
</div>


          </div>         
        </div>
      </div>
      
        
          <div class="yui-b" id="sidebar">
            
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../contents.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Logging</a><ul>
<li><a class="reference internal" href="#a-quick-logging-primer">A quick logging primer</a><ul>
<li><a class="reference internal" href="#the-cast-of-players">The cast of players</a><ul>
<li><a class="reference internal" href="#loggers">Loggers</a></li>
<li><a class="reference internal" href="#handlers">Handlers</a></li>
<li><a class="reference internal" href="#filters">Filters</a></li>
<li><a class="reference internal" href="#formatters">Formatters</a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#using-logging">Using logging</a><ul>
<li><a class="reference internal" href="#naming-loggers">Naming loggers</a></li>
<li><a class="reference internal" href="#making-logging-calls">Making logging calls</a></li>
</ul>
</li>
<li><a class="reference internal" href="#configuring-logging">Configuring logging</a><ul>
<li><a class="reference internal" href="#examples">Examples</a></li>
<li><a class="reference internal" href="#custom-logging-configuration">Custom logging configuration</a></li>
<li><a class="reference internal" href="#disabling-logging-configuration">Disabling logging configuration</a></li>
</ul>
</li>
<li><a class="reference internal" href="#django-s-logging-extensions">Django&#8217;s logging extensions</a><ul>
<li><a class="reference internal" href="#id2">Loggers</a><ul>
<li><a class="reference internal" href="#django"><tt class="docutils literal"><span class="pre">django</span></tt></a></li>
<li><a class="reference internal" href="#django-request"><tt class="docutils literal"><span class="pre">django.request</span></tt></a></li>
<li><a class="reference internal" href="#django-db-backends"><tt class="docutils literal"><span class="pre">django.db.backends</span></tt></a></li>
<li><a class="reference internal" href="#django-security"><tt class="docutils literal"><span class="pre">django.security.*</span></tt></a></li>
</ul>
</li>
<li><a class="reference internal" href="#id3">Handlers</a></li>
<li><a class="reference internal" href="#id4">Filters</a></li>
</ul>
</li>
<li><a class="reference internal" href="#django-s-default-logging-configuration">Django&#8217;s default logging configuration</a></li>
</ul>
</li>
</ul>

  <h3>Browse</h3>
  <ul>
    
      <li>Prev: <a href="localflavor.html">The &#8220;local flavor&#8221; add-ons</a></li>
    
    
      <li>Next: <a href="pagination.html">Pagination</a></li>
    
  </ul>
  <h3>You are here:</h3>
  <ul>
      <li>
        <a href="../index.html">Django 1.6.7 documentation</a>
        
          <ul><li><a href="index.html">Using Django</a>
        
        <ul><li>Logging</li></ul>
        </li></ul>
      </li>
  </ul>  

  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../_sources/topics/logging.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
              <h3>Last update:</h3>
              <p class="topless">Sep 26, 2014</p>
          </div> 
        
      
    </div>
    
    <div id="ft">
      <div class="nav">
    &laquo; <a href="localflavor.html" title="The &amp;#8220;local flavor&amp;#8221; add-ons">previous</a> 
     |
    <a href="index.html" title="Using Django" accesskey="U">up</a>
   |
    <a href="pagination.html" title="Pagination">next</a> &raquo;</div>
    </div>
  </div>

      <div class="clearer"></div>
    </div>
  </body>
</html>