title: Python, Flask, Elasticbeanstalk Logging
body: <p>I am trying to use Elasticbeanstalk to deploy a Flask REST API. Logging and the application works with no issues on my test system. However, I am not getting the logs from the ebs instance using the request logs from AWS console. </p>
  
  <p>Read stackoverflow <a href="https://stackoverflow.com/questions/15038135/python-on-the-aws-beanstalk-how-to-snapshot-custom-logs">article</a> and AWS <a href="http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html" rel="noreferrer">docs</a> but couldn't set it up correctly. </p>
  
  <p>My application logging setup:</p>
  
  <pre><code>logger = logging.getLogger(__name__)
  formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
  logger.setLevel(logging.DEBUG)
  handler = RotatingFileHandler('/opt/python/log/application.log', maxBytes=1024,backupCount=5)
  handler.setFormatter(formatter)
  application = Flask(__name__)
  application.logger.addHandler(handler)
  </code></pre>
  
  <p>Usage:</p>
  
  <pre><code>logger.debug(email)
  </code></pre>
  
  <p>Config file in .ebextensions (tried with and without)</p>
  
  <pre><code>files:
    "/opt/python/log/application.log" :
     mode: "000666"
     owner: ec2-user
     group: ec2-user
     content: |
        # Python log file
  </code></pre>
  
  <p>When I request last 100 lines of logs there are no logs except what I put in the content section in ebextension config.</p>
  
  <pre><code>-------------------------------------
  /opt/python/log/application.log
  -------------------------------------
  # Python log file
  </code></pre>
  
  <p>What am I missing? </p>