title: Is it good design to create a module-wide logger in python?
body: <p>When coding python, I use the logging module a lot.</p>
  
  <p>After some bad experiences and reading articles like <a href="http://plope.com/Members/chrism/import_time_side_effectsrism/import_time_side_effects" rel="noreferrer">this one</a>, I try to prevent import-time executed code wherever possible.</p>
  
  <p>However, for the sake of simplicity, I tend to get my logging object right at the beginning of the module file:</p>
  
  <pre><code># -*- coding: utf-8 -*-
  import logging
  logger = logging.getLogger('product.plugin.foo.bar')
  </code></pre>
  
  <p>This way, my logger is globally accessible and I can just write "logger.error()" anywhere. The alternative is to create it class-wide:</p>
  
  <pre><code>class Bar(object):
      logger = logging.getLogger('product.plugin.foo.bar')
  </code></pre>
  
  <p>However, now I have to type the Class name everytime. To prevent typing the class name, I am tempted to use "self" instead, which will fail in static methods.</p>
  
  <pre><code>    def my_method(self):
          Bar.logger.error('foo')
  
      def my_method_2(self):
          self.logger.error('foo') # ok...
  
      @staticmethod
      def my_method_2():
          self.logger.error('foo') # boom!
  </code></pre>
  
  <p>So, at first, it looks like creating the logger object module-wide seems like the right thing to do - still it feels like I could end up in import-related trouble when doing it like this...</p>