title: How can I log outside of main Flask module?
body: <p>I have a Python Flask application, the entry file configures a logger on the app, like so:</p>
  
  <pre><code>app = Flask(__name__)
  handler = logging.StreamHandler(sys.stdout)
  app.logger.addHandler(handler)
  app.logger.setLevel(logging.DEBUG)
  </code></pre>
  
  <p>I then do a bunch of logging using </p>
  
  <p><code>app.logger.debug("Log Message")</code></p>
  
  <p>which works fine. However, I have a few API functions like:</p>
  
  <pre><code>@app.route('/api/my-stuff', methods=['GET'])
  def get_my_stuff():
      db_manager = get_manager()
      query = create_query(request.args)
  
      service = Service(db_manager, query)
      app.logger.debug("Req: {}".format(request.url))
  </code></pre>
  
  <p>What I would like to know is how can I do logging within that <code>Service</code> module/python class. Do I have to pass the app to it? That seems like a bad practice, but I don't know how to get a handle to the app.logger from outside of the main Flask file...</p>