I am running my code using gunicorn like this way :
gunicorn --bind 0.0.0.0:6435 --access-logfile=allOuts.log --error-logfile=allErs.log --certfile=cert.pem --keyfile=key.pem --ssl-version=5 --ciphers=EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH app:app -w=5 --timeout=500 --daemon
And my logging module code is :
import logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-8s %(message)s', datefmt='%a, %d %b %Y %H:%M:%S', filename='/app/python/logs/firstlogs.log', filemode='w')
# create console handler and set level to debug
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
# create formatter
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s\n')
# add formatter to ch
ch.setFormatter(formatter)
# add ch to logger
logger.addHandler(ch)
But I can only see some logs. My intuition is I am able to see some logs which are only from one particular worker. How do I direct logs from all workers to same log file? Or how can i maintain different log files for different workers?
I went through a similar question here : How to use the logging module in Python with gunicorn but could not find a solution