11

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.

Read stackoverflow article and AWS docs but couldn't set it up correctly.

My application logging setup:

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)

Usage:

logger.debug(email)

Config file in .ebextensions (tried with and without)

files:
  "/opt/python/log/application.log" :
   mode: "000666"
   owner: ec2-user
   group: ec2-user
   content: |
      # Python log file

When I request last 100 lines of logs there are no logs except what I put in the content section in ebextension config.

-------------------------------------
/opt/python/log/application.log
-------------------------------------
# Python log file

What am I missing?

Community
  • 1
  • 1
sm-azure
  • 307
  • 3
  • 12
  • 1
    I am having the same issue, can't see any errors in any other log and application seems to be running normally except for the logs. – Goran Feb 05 '18 at 00:38
  • How did you solve your issue?! – leoschet Aug 29 '18 at 16:55
  • 1
    Writing to `/opt/python/log` should work, without explicitly creating the file in `.ebextensions`. If you do create the file in `.ebextensions`, make sure that owner and/or group are `wsgi` (with write permission), because your Python app will run as `wsgi:wsgi`. Also see [this explanation](https://stackoverflow.com/a/60549321). – djvg Mar 06 '20 at 08:17

0 Answers0