title: Python - Logger over multiple files
body: <p>I created a module named <strong>log.py</strong> where a function defines how the log will be registered. Here is the atomic code:</p>
  
  <pre><code>import logging
  import time
  
  def set_up_log():
      """
      Create a logging file.
      """ 
      #
      # Create the parent logger.
      #
      logger = logging.getLogger(__name__)
      logger.setLevel(logging.INFO)
      #
      # Create a file as handler.
      #
      file_handler = logging.FileHandler('report\\activity.log')
      file_handler.setLevel(logging.INFO)
      formatter = logging.Formatter('%(asctime)s - %(filename)s - %(name)s - %  (levelname)4s - %(message)s')
      file_handler.setFormatter(formatter)
      logger.addHandler(file_handler)
      #
      # Start recording.
      #
      logger.info('______ STARTS RECORDING _______')
  
  if __name__=='__main__':
      set_up_log()
  </code></pre>
  
  <p>A second module named <strong>read_file.py</strong> is using this <strong>log.py</strong> to record potential error. </p>
  
  <pre><code>import logging
  import log
  log.set_up_log()
  logger = logging.getLogger(__name__)
  
  
  def read_bb_file(input_file):
      """
      Input_file must be the path.
      Open the source_name and read the content. Return the result.
      """
      content = list()
      logger.info('noi')
      try:
          file = open(input_file, 'r')
      except IOError, e:
          logger.error(e)
      else:
          for line in file:
              str = line.rstrip('\n\r')
              content.append(str)
          file.close()
          return content
  
  if __name__ == "__main__":
      logger.info("begin execution")
      c = read_bb_file('textatraiter.out')
      logger.info("end execution")
  </code></pre>
  
  <p>In the command prompt lauching <strong>read_file.py</strong>, I get this error:</p>
  
  <p><code>No handlers could be found for logger "__main__"</code></p>
  
  <p>My result in the file is the following</p>
  
  <p><code>2014-05-12 13:32:58,690 - log.py - log - INFO - ______ STARTS RECORDING _______</code></p>
  
  <p>I read lots of topics here and on Py Doc but it seems I did not understand them properly since I have this error.
  I add I would like to keep the log settlement appart in a function and not define it explicitely in my main method.</p>