Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django Gunicorn where logs are stored

I have deployed my app using some tutorial

I use nginx+gunicorn (also I use systemd)

Right now everything works fine on my dev server But on production it fails with Internal Server Error when I try to download file

How and where can I find gunicorn logs? (I use ubuntu)

Also, this is piece of code that causes an error just in case:

def download_xlsx(request):
    user = request.user
    file_name = request.GET['file_name']
    file_path='main_app/static/xlsx/' + str(user.id) + '/' + file_name
    disposition= 'attachment; filename="' +smart_str(file_name) + '"'
    disposition=disposition.encode('utf-8')
    if os.path.exists(file_path):
        with open(file_path, 'rb') as fh:
            response = HttpResponse(fh.read(), content_type="application/vnd.ms-excel")
            response['Content-Disposition'] = disposition
            return response
    return projects.to_utf8_json_response('not found')

UPD: I tried to run sudo journalctl -u gunicorn

But I get as a result a huge file starting 2 month ago, so I can't go to latest logs do to it's size

like image 229
user2950593 Avatar asked Sep 06 '18 09:09

user2950593


1 Answers

Seems to work like this:

journalctl --unit=gunicorn | tail -n 300
like image 136
user2950593 Avatar answered Nov 15 '22 03:11

user2950593