title: Log to same file from different scripts?
body: <p>I have a top level <code>main.py</code> that calls <code>core.py</code>. I'd like both files write to the same long. My code:</p>
  
  <p>File <code>main.py</code>:</p>
  
  <pre><code>import core
  
  import logging
  logger = logging.getLogger(__name__)
  logger.setLevel(logging.DEBUG)
  
  ch = logging.StreamHandler()
  ch.setLevel(logging.DEBUG)
  logger.addHandler(ch)
  
  fh = logging.FileHandler("main.log",mode="w")
  fh.setLevel(logging.DEBUG)
  logger.addHandler(fh)
  
  logger.info("I am in main.")
  
  core.myclass()
  </code></pre>
  
  <p>File <code>core.py</code>:</p>
  
  <pre><code>import logging
  class myclass():
      def __init__(self):
          logger = logging.getLogger("main")
          print(logger)
          logger.debug("Debug message")
          logger.warn("Warning message")
  </code></pre>
  
  <p>From my understanding, the line
  <code>logger = logging.getLogger("main")</code> should get a reference to the original log, so I need not set it up again. However, the messages from <code>core.py</code> are at the default warn level, and are not written to the file.</p>
  
  <p>Any way to maintain the same setup across different modules?</p>