title: python logger with threading misbehaving
body: <p>I am using python 2.7 to log into a file some messages that are included in threaded calls. However, instead of having the message 1 time, I have the log occurring 3 times . Well, I set a range equals to 5, however, the message is occurring 15 times.</p>
  
  <p>Below is the code :</p>
  
  <pre><code>import sys
  import logging
  import threading  
  import logging.handlers
  import time 
  import os 
  
  ETT="TVAR 1"
  objectname="TVAR 2"
  URLFORLOG="TVAR 3"
  
  def setup_custom_logger(name):
      fileLogName='visualreclogfile.log'
      #formatter = logging.Formatter(fmt='%(asctime)s - %(levelname)s - %(module)s - %(message)s')
      formatter = logging.Formatter(fmt='%(asctime)s - %(levelname)s - %(message)s')
  
      handlerCH = logging.StreamHandler()
      handlerCH.setFormatter(formatter)
  
      handlerFILE = logging.handlers.RotatingFileHandler(fileLogName, maxBytes=(1048576*5), backupCount=7)
      handlerFILE.setFormatter(formatter)
  
  
      logger = logging.getLogger(name)
      logger.setLevel(logging.INFO)
  
      logger.addHandler(handlerCH)
      logger.addHandler(handlerFILE)
  
      return logger
  
  def LoggingFileForELK(MessageToBeLogged):
      logger = setup_custom_logger('root')
      logger.info(MessageToBeLogged)
  
  
  def mainFunction():
      Messages=("*** CONTENT LOGGING *** OBJECT UUID : %s WITH NAME KEY : %s HAS URL : %s ") %(ETT,objectname,URLFORLOG)
      MessageToBeLogged=str(Messages)
      LoggingFileForELK(MessageToBeLogged)
  
  
  
  
  
  threads = []
  for i in range(5):
      t = threading.Thread(target=mainFunction)
      threads.append(t)
      t.start()
      time.sleep(0.5)
  for  t in threads:
      t.join()
  </code></pre>
  
  <p>Below is my result :</p>
  
  <pre><code>2017-04-22 12:36:59,010 - INFO - *** CONTENT LOGGING *** OBJECT UUID : TVAR 1 WITH NAME KEY : TVAR 2 HAS URL : TVAR 3
  2017-04-22 12:36:59,512 - INFO - *** CONTENT LOGGING *** OBJECT UUID : TVAR 1 WITH NAME KEY : TVAR 2 HAS URL : TVAR 3
  2017-04-22 12:36:59,512 - INFO - *** CONTENT LOGGING *** OBJECT UUID : TVAR 1 WITH NAME KEY : TVAR 2 HAS URL : TVAR 3
  2017-04-22 12:37:00,018 - INFO - *** CONTENT LOGGING *** OBJECT UUID : TVAR 1 WITH NAME KEY : TVAR 2 HAS URL : TVAR 3
  2017-04-22 12:37:00,018 - INFO - *** CONTENT LOGGING *** OBJECT UUID : TVAR 1 WITH NAME KEY : TVAR 2 HAS URL : TVAR 3
  2017-04-22 12:37:00,018 - INFO - *** CONTENT LOGGING *** OBJECT UUID : TVAR 1 WITH NAME KEY : TVAR 2 HAS URL : TVAR 3
  2017-04-22 12:37:00,520 - INFO - *** CONTENT LOGGING *** OBJECT UUID : TVAR 1 WITH NAME KEY : TVAR 2 HAS URL : TVAR 3
  2017-04-22 12:37:00,520 - INFO - *** CONTENT LOGGING *** OBJECT UUID : TVAR 1 WITH NAME KEY : TVAR 2 HAS URL : TVAR 3
  2017-04-22 12:37:00,520 - INFO - *** CONTENT LOGGING *** OBJECT UUID : TVAR 1 WITH NAME KEY : TVAR 2 HAS URL : TVAR 3
  2017-04-22 12:37:00,520 - INFO - *** CONTENT LOGGING *** OBJECT UUID : TVAR 1 WITH NAME KEY : TVAR 2 HAS URL : TVAR 3
  2017-04-22 12:37:01,022 - INFO - *** CONTENT LOGGING *** OBJECT UUID : TVAR 1 WITH NAME KEY : TVAR 2 HAS URL : TVAR 3
  2017-04-22 12:37:01,022 - INFO - *** CONTENT LOGGING *** OBJECT UUID : TVAR 1 WITH NAME KEY : TVAR 2 HAS URL : TVAR 3
  2017-04-22 12:37:01,022 - INFO - *** CONTENT LOGGING *** OBJECT UUID : TVAR 1 WITH NAME KEY : TVAR 2 HAS URL : TVAR 3
  2017-04-22 12:37:01,022 - INFO - *** CONTENT LOGGING *** OBJECT UUID : TVAR 1 WITH NAME KEY : TVAR 2 HAS URL : TVAR 3
  2017-04-22 12:37:01,022 - INFO - *** CONTENT LOGGING *** OBJECT UUID : TVAR 1 WITH NAME KEY : TVAR 2 HAS URL : TVAR 3
  </code></pre>
  
  <p>I looked at this stackoverflow <a href="https://stackoverflow.com/questions/38384065/python-using-logger-with-multiple-handlers">thread</a> but no answer here. </p>
  
  <p>I cannot see the wrong part code... </p>