title: Python logging: subloggers or extra information
body: <p>I have a Python application that uses dynamically discovered plugins to extends it capabilities. I am trying to figure out what is the best way to log information from the plugins. I think there are at least two solutions. Either I create a hierarchy of loggers:</p>
  
  <pre><code>myapp
  myapp.plugin1
  myapp.plugin2
  </code></pre>
  
  <p>And withing the base app:</p>
  
  <pre><code>logger = logging.getLogger('myapp')
  logger.debug('mymessage')
  </code></pre>
  
  <p>and withing the plugin1</p>
  
  <pre><code>logger = logging.getLogger('myapp.plugin1')
  logger.debug('mymessage from plugin1')
  </code></pre>
  
  <p>Or I add additional information using the <code>extra</code> parameter in the default logger:
  Within base app:</p>
  
  <pre><code>logger = logging.getLogger('myapp')
  logger.debug('mymessage', extra=dict(plugin=None)
  </code></pre>
  
  <p>Within plugin1</p>
  
  <pre><code>logger = logging.getLogger('myapp')
  logger.debug('mymessage from plugin1', extra=dict(plugin='plugin1')
  </code></pre>
  
  <p>What are the advantages or disadvantages (if any) between these two schemes?</p>