title: Python logging from library module
body: <p>I am trying to setup generic logging in my Python library modules so that they use the logger configured in the calling module without having to hard code a logger name. I've seen plenty of examples using <code>logging.basicConfig()</code> in the calling module and calling <code>logging.debug()</code> in the library module, but it doesn't work when I configure my own StreamHandler. What am I doing wrong? </p>
  
  <p>This is my calling module:</p>
  
  <pre><code>import logging, logging.handlers
  logger = logging.getLogger(__name__)
  logger.setLevel(logging.INFO)
  consolehandler = logging.StreamHandler()
  consoleformatter = logging.Formatter('[%(name)s] %(levelname)s %(message)s')
  consolehandler.setFormatter(consoleformatter)
  logger.addHandler(consolehandler)
  import libmodule
  
  def run():
      logger.info("message from calling module")
      libmodule.say("message from library module")
  </code></pre>
  
  <p>I've tried this in libmodule.py:</p>
  
  <pre><code>import logging
  
  def say(msg):
      logging.info(msg)
  </code></pre>
  
  <p>and this:</p>
  
  <pre><code>import logging
  logger = logging.getLogger()
  
  def say(msg):
      logger.info(msg)
  </code></pre>
  
  <p>But in both cases when I call run(), I get this output:</p>
  
  <pre><code>[callingmodule] INFO message from calling module
  </code></pre>
  
  <p>but was expecting this:</p>
  
  <pre><code>[callingmodule] INFO message from calling module
  [callingmodule] INFO message from library module
  </code></pre>