title: Python logging - Is there something below DEBUG?
body: <p>In some other technologies we occasionally used a log level below DEBUG that I believe was called "verbose".  I realize that the need for such a level is very subjective.  But in my mind "just" having INFO and DEBUG isn't really enough.  We had times where something very spammy (more spammy than debug) needed to be logged.  In practice we'd produce builds without this turned on but in a few occasions we'd enable this level of logging after the product was all installed on some QA setup, while tracking down a bug, etc.</p>
  
  <p>Is there any way (easy or otherwise) to log something below the DEBUG level using the standard python logging library?</p>
  
  <p>In a temp.py file I can do the following:</p>
  
  <pre><code>logging.addLevelName(5,"verbose")
  VERBOSE = 5
  
  logger = logging.getLogger("foo")
  logger.setLevel(VERBOSE)
  logger.log(VERBOSE,"blah!")
  </code></pre>
  
  <p>This works when I run temp.py within my IDE (and logs to stdout) but our real daemons use the standard file/dictionary configuration syntax to setup logging and I don't see any way to indicate that level 5 should be used for the daemon.</p>
  
  <p>Am I chasing something that's not really feasible?</p>
  
  <p>For those who might wonder why I'd need anything lower than DEBUG, it's for the occasional type of logging that might occur very frequently (maybe an inner loop) that I wouldn't normally want to see even at DEBUG but on some production system it might be helpful to enable it once in awhile without needing to add more logging to the source code and re-deploy, etc.</p>
  
  <p>EDIT1 - Clearly the logging library allows for custom levels.  Since DEBUG is level 10, there's room somewhere in the 1..9 range.  If I define a custom level (such as in the sample code above), I guess my real question is how do I enable that level of logging from the json log configuration file?</p>
  
  <p>EDIT2 - The following would work if it weren't for the fact that we need/use json configuration files (a requirement that I cannot change):</p>
  
  <pre><code>import logging
  
  logging.basicConfig(filename='example.log',level=5)
  VERBOSE = 5
  logging.addLevelName(5,"verbose")
  logger = logging.getLogger("bar")
  logger.log(VERBOSE,"blah!")
  </code></pre>
  
  <p>EDIT3 - Figured it out...  The call to</p>
  
  <pre><code>logging.addLevelName(5,"VERBOSE")
  </code></pre>
  
  <p>is critical.  I just didn't have it in the right place.  In my case I just needed to make the above call takes place <em>before</em> the call to the logging libraries dictConfig(...) call.  After I did this I was then able to go into our log configuration file and bump things down (on both the file handler and the root) to VERBOSE and it worked.</p>
  
  <p>Granted, the log statement itself isn't exactly elegant because you call:</p>
  
  <pre><code>self.logger.log(VERBOSE,"Something very spammy")
  </code></pre>
  
  <p>rather than</p>
  
  <pre><code>self.logger.verbose("Something very spammy")
  </code></pre>
  
  <p>But I really didn't want to modify any logger library code (been there, done that, have the t-shirt).</p>
  
  <p>Thanks all!</p>
  
  <p>And to those who think nothing lower than DEBUG is needed, more power to you :)</p>