title: How to add a custom loglevel to Python's logging facility
body: <p>I'd like to have loglevel TRACE (5) for my application, as I don't think that <code>debug()</code> is sufficient. Additionally <code>log(5, msg)</code> isn't what I want. How can I add a custom loglevel to a Python logger?</p>
  <p>I've a <code>mylogger.py</code> with the following content:</p>
  <pre><code>import logging
  
  @property
  def log(obj):
      myLogger = logging.getLogger(obj.__class__.__name__)
      return myLogger
  </code></pre>
  <p>In my code I use it in the following way:</p>
  <pre><code>class ExampleClass(object):
      from mylogger import log
  
      def __init__(self):
          '''The constructor with the logger'''
          self.log.debug(&quot;Init runs&quot;)
  </code></pre>
  <p>Now I'd like to call <code>self.log.trace(&quot;foo bar&quot;)</code></p>
  <p><strong>Edit</strong> (Dec 8th 2016): I changed the accepted answer to <a href="https://stackoverflow.com/a/13638084/600110">pfa's</a> which is, IMHO, an excellent solution based on the very good proposal from Eric S.</p>