title: How to send calling class name to logger class in Python >
body: <p>I am new to Python and trying to implement logger in my code.
  I have created a python file: setup_logger.py</p>
  
  <pre><code>import logging
  
  CLASS_NAME = ''
  
  # Create and configure logger
  LOG_FORMAT = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
  logging.basicConfig(filename='/Users/bobby/Desktop/lumberjack.log', level=logging.DEBUG, format=LOG_FORMAT)
  logger = logging.getLogger()
  </code></pre>
  
  <p>I am using this logger configuration in another python file: GetLogger.py as below</p>
  
  <pre><code>from LoggerLevels.setup_logger import logger
  
  if __name__ == '__main__':
      logger.error('This is a basic log error message')
      logger.info('This is a warning message')
  </code></pre>
  
  <p>The log is being printed in the file as:</p>
  
  <pre><code>2020-06-17 14:54:47,161 - root - ERROR - This is a basic log error message
  2020-06-17 14:54:47,161 - root - INFO - This is a warning message
  </code></pre>
  
  <p>But I see the class name is printed as <code>root</code>. I understand that it is coming due to the setting in <code>setup_logger.py</code> file. 
  Is there anyway I can send the current class name that is logging messages into my file ?
  For ex: 
  I am using the logger object from <code>GetLogger.py</code> file. Is there anyway I can log the message as</p>
  
  <pre><code>2020-06-17 14:54:47,161 - GetLogger - ERROR - This is a basic log error message
  2020-06-17 14:54:47,161 - GetLogger - INFO - This is a warning message
  </code></pre>
  
  <p>Could anyone let me know how can I achieve that ?</p>