Find gunicorn log file in docker container
Asked Answered
S

2

14

I have a docker container running a python service with gunicorn. This is how the service was started :

gunicorn --bind 0.0.0.0:6435 --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

But, i am unable to find log files for the 5 workers. What would be the default path to find these log files?

I tried using the find command find / -type f -name "hs_err_pid" since these are the default file names gunicorn saves the log files with. But this gives me the following permission errors:

    find: ‘/proc/1/map_files’: Operation not permitted
find: ‘/proc/16/map_files’: Operation not permitted
find: ‘/proc/89/map_files’: Operation not permitted

Any way to find out the log files?

Sadoc answered 7/11, 2019 at 11:13 Comment(0)
D
10

I suggest you to add --access-logfile YOUR_FILE to your command to specify a file or redirect it to stdout using -. the same goes for error logs.

see this

Doyledoyley answered 7/11, 2019 at 11:17 Comment(4)
Thanks for the suggestion. Yes, thats what we are doing for the new deployment, just wanted to check if we could get the previous logsSadoc
for the error logs : Changed in version 19.2: Log to stderr by default. so docker logs should be the place to see them. I thinkDoyledoyley
there is no syslog folder in /var/log/ :(Sadoc
sorry for the late reply.. nothing there also which would have these logsSadoc
R
1

If you are doing it via a shell script.

gunicorn --chdir myapp myapp.asgi:application \
    -k uvicorn.workers.UvicornWorker \
    --name apipa \
    --bind 0.0.0.0:5555 \
    --access-logfile - \
    --error-logfile - 

If you are using a gunicorn config file

gunicorn your_app.wsgi:application -c /path/to/gunicorn.conf.py  

with contents of the gunicorn.conf.py as

bind = "0.0.0.0:5555"  
accesslog = "-"  
errorlog = "-"  
Registrant answered 11/1 at 19:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.