title: Python Logging - AttributeError: module 'logging' has no attribute 'handlers'
body: <p>Observation: When I comment out <code>from logging import handlers</code> the below-mentioned error is observed.</p>
  <pre><code>Error:
      file_handler =  logging.handlers.RotatingFileHandler(
  AttributeError: module 'logging' has no attribute 'handlers'
  </code></pre>
  <p>Question: If i have imported the <code>logging</code> why is required to do <code>from logging import handlers</code>?</p>
  <pre><code>import logging
  import sys
  #from logging import handlers
  
  def LoggerDefination():
      #file_handler = logging.FileHandler(filename='..\\logs\\BasicLogger_v0.1.log', mode='a')
      file_handler =  logging.handlers.RotatingFileHandler(
          filename=&quot;..\\logs\\BasicLogger_v0.2.log&quot;,
          mode='a',
          maxBytes=20000,
          backupCount=7,
          encoding=None,
          delay=0
      )
      file_handler.setLevel(logging.DEBUG)
  
      stdout_handler = logging.StreamHandler(sys.stdout)
      stdout_handler.setLevel(logging.DEBUG)
      handlers = [file_handler, stdout_handler]
  
      logging.basicConfig(
          level=logging.DEBUG,
          format='%(asctime)s | %(module)s | %(name)s | LineNo_%(lineno)d | %(levelname)s |  %(message)s',
          handlers=handlers
      )
  
  def fnt_test_log1():
      LoggerDefination()
      WriteLog1 = logging.getLogger('fnt_test_log1')
      #WriteLog1.propagate=False
      WriteLog1.info(&quot;######## START OF : test_log1 ##########&quot;)
      WriteLog1.debug(&quot;test_log1 | This is debug level&quot;)
      WriteLog1.debug(&quot;test_log1 | This is debug level&quot;)
      WriteLog1.info(&quot;test_log1 | This is info level&quot;)
      WriteLog1.warning(&quot;test_log1 | This is warning level&quot;)
      WriteLog1.error(&quot;test_log1 | This is error level&quot;)
      WriteLog1.critical(&quot;test_log1 |This is critiacl level&quot;)
      WriteLog1.info(&quot;######## END OF : test_log1 ##########&quot;)
  
  
  def fnt_test_log2():
      LoggerDefination()
      WriteLog2 = logging.getLogger('fnt_test_log2')
      WriteLog2.info(&quot;######## START OF : test_log2 ##########&quot;)
      WriteLog2.debug(&quot;test_log2 ===&gt; debug&quot;)
      WriteLog2.debug(&quot;test_log2 | This is debug level&quot;)
      WriteLog2.debug(&quot;test_log2 | This is debug level&quot;)
      WriteLog2.info(&quot;test_log2 | This is info level&quot;)
      WriteLog2.warning(&quot;test_log2 | This is warning level&quot;)
      WriteLog2.error(&quot;test_log2 | This is error level&quot;)
      WriteLog2.critical(&quot;test_log2 |This is critiacl level&quot;)
      WriteLog2.info(&quot;######## STOP OF : test_log2 ##########&quot;)
  
  
  if __name__ == '__main__':
      LoggerDefination()
      MainLog = logging.getLogger('main')
      LoggerDefination()
      MainLog.info(&quot;Executing script: &quot; + __file__)
      fnt_test_log1()
      fnt_test_log2()
  </code></pre>