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?