title: Logging using elasticsearch-py
body: <p>I would like to log my <code>python</code> script that uses <code>elasticsearch-py</code>. In particular, I want to have three logs:</p>
  
  <ol>
  <li><strong>General log:</strong> log <code>INFO</code> and above both to the <code>stdout</code> and to a file.</li>
  <li><strong>ES log:</strong> only ES related messages only to a file.</li>
  <li><strong>ES tracing log</strong>: Extended ES logging (curl queries and their output for instance) only to a file.</li>
  </ol>
  
  <p>Here is what I have so far:</p>
  
  <p></p>
  
  <pre><code>import logging
  import logging.handlers
  
  es_logger = logging.getLogger('elasticsearch')
  es_logger.setLevel(logging.INFO)
  es_logger_handler=logging.handlers.RotatingFileHandler('top-camps-base.log',
                                                            maxBytes=0.5*10**9,
                                                            backupCount=3)
  es_logger.addHandler(es_logger_handler)
  
  es_tracer = logging.getLogger('elasticsearch.trace')
  es_tracer.setLevel(logging.DEBUG)
  es_tracer_handler=logging.handlers.RotatingFileHandler('top-camps-full.log',
                                                         maxBytes=0.5*10**9,
                                                         backupCount=3)
  es_tracer.addHandler(es_tracer_handler)
  
  logger = logging.getLogger('mainLog')
  logger.setLevel(logging.DEBUG)
  # create file handler
  fileHandler = logging.handlers.RotatingFileHandler('top-camps.log',
                                                     maxBytes=10**6,
                                                     backupCount=3)
  fileHandler.setLevel(logging.INFO)
  # create console handler
  consoleHandler = logging.StreamHandler()
  consoleHandler.setLevel(logging.INFO)
  # create formatter and add it to the handlers
  formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
  consoleHandler.setFormatter(formatter)
  fileHandler.setFormatter(formatter)
  # add the handlers to logger
  logger.addHandler(consoleHandler)
  logger.addHandler(fileHandler)
  </code></pre>
  
  <p>My problem is that <code>INFO</code> messages of <code>es_logger</code> are displayed also on the terminal. As a matter of fact the log messages are saved to the right files!</p>
  
  <p>If I remover the part related to <code>logger</code>, then the ES logging works fine, i.e. only saved to the corresponding files. But then I don't have the other part.... What is it that I'm doing wrong with the last part of the settings?</p>
  
  <hr>
  
  <h1>Edit</h1>
  
  <p>Possible hint: In the sources of <code>elasticsearch-py</code> there's a logger named <code>logger</code>. Could it be that it conflicts with mine? I tried to change the name of <code>logger</code> to <code>main_logger</code> in the lines above but it didn't help.</p>
  
  <p>Possible hint 2: If I replace <code>logger = logging.getLogger('mainLog')</code> with <code>logger = logging.getLogger()</code>, then the format of the output to the console of <code>es_logger</code> changes and becomes identical to the one defined in the snippet.</p>