Coder Social home page Coder Social logo

Comments (10)

NixBiks avatar NixBiks commented on June 17, 2024 1

@victornoel did you find a solution to this? I am getting info logs from uvicorn.access although I have LOG_LEVEL set to warning in gunicorn.

from uvicorn-gunicorn-docker.

NixBiks avatar NixBiks commented on June 17, 2024

+1

from uvicorn-gunicorn-docker.

victornoel avatar victornoel commented on June 17, 2024

@mr-bjerre I ended up configuring a ini config file with this inside (I omitted the other things in it):

    [logger_gunicorn]
    level=INFO
    handlers=console
    propagate=0
    qualname=gunicorn

    [logger_gunicorn_access]
    level=WARNING
    handlers=console
    propagate=0
    qualname=gunicorn.access

And I pass it to gunicorn via --log-config (it means I run gunicorn by hand). I suppose #21 would be helpflu there.

from uvicorn-gunicorn-docker.

tiangolo avatar tiangolo commented on June 17, 2024

You can now set (or disable) the access log with: https://github.com/tiangolo/uvicorn-gunicorn-docker#access_log 🎉

And you can also pass Gunicorn configs in an env var: https://github.com/tiangolo/uvicorn-gunicorn-docker#gunicorn_cmd_args

from uvicorn-gunicorn-docker.

joshzana avatar joshzana commented on June 17, 2024

It looks like this works when running gunicorn in start.sh, but is ignored in start-reload.sh. Would be great to get that script to run exec uvicorn --reload --no-access-log when ACCESS_LOG is unset.

from uvicorn-gunicorn-docker.

tiangolo avatar tiangolo commented on June 17, 2024

@joshzana start-reload.sh is exclusively for local development, just as a simple, small, shortcut. You shouldn't use it for production. It will only use a single process and will use a lot more resources (memory, etc) watching files, etc.

But anyway, if for some reason you still need custom logic during development, you can also write a small script using start-reload.sh as template, and running that.

from uvicorn-gunicorn-docker.

github-actions avatar github-actions commented on June 17, 2024

Assuming the original issue was solved, it will be automatically closed now. But feel free to add more comments or create new issues.

from uvicorn-gunicorn-docker.

cjmcgraw avatar cjmcgraw commented on June 17, 2024

This problem persists for me.

I am running a container. Viewing the stdout/stderr of the container.

I currently have the following gunicorn_conf.py set in my /app/gunicorn_conf.py:

# Gunicorn config variables
loglevel = "info"
workers = 2
threads = 8
bind = "0.0.0.0:80"

preload_app = False
statsd_host = "statsd:8125"
statsd_prefix = "recsys"
timeout = 180
keepalive = 120
accesslog = None
errorlog = "-"

While changing the accesslog parameter to stdout ("-") has gunicorn log. Uvicorn still is logging no matter what I do:

INFO:uvicorn.access:127.0.0.1:36678 - "GET /health/test HTTP/1.1" 200
INFO:uvicorn.access:172.17.0.1:46740 - "GET / HTTP/1.1" 200
INFO:uvicorn.access:172.17.0.1:46744 - "GET / HTTP/1.1" 200
INFO:uvicorn.access:172.17.0.1:46748 - "GET / HTTP/1.1" 200
INFO:uvicorn.access:172.17.0.1:46752 - "GET / HTTP/1.1" 200
INFO:uvicorn.access:172.17.0.1:46756 - "GET / HTTP/1.1" 200
INFO:uvicorn.access:172.17.0.1:46760 - "GET / HTTP/1.1" 200
INFO:uvicorn.access:172.17.0.1:46764 - "GET / HTTP/1.1" 200
INFO:uvicorn.access:172.17.0.1:46768 - "GET / HTTP/1.1" 200
INFO:uvicorn.access:172.17.0.1:46772 - "GET / HTTP/1.1" 200
INFO:uvicorn.access:172.17.0.1:46776 - "GET / HTTP/1.1" 200
INFO:uvicorn.access:172.17.0.1:46780 - "GET / HTTP/1.1" 200
INFO:uvicorn.access:172.17.0.1:46784 - "GET / HTTP/1.1" 200
INFO:uvicorn.access:172.17.0.1:46788 - "GET / HTTP/1.1" 200

Using the ACCESS_LOG parameter (or manually setting it in my gunicorn_conf.py) seems to have absolutely no effect on that log printing out.

I have yet to follow the advice of @victornoel and change out the logging configuration. I am wondering if we have a more direct and clear solution to this problem.

from uvicorn-gunicorn-docker.

cjmcgraw avatar cjmcgraw commented on June 17, 2024

Following up on my previous post. If I clear out uvicorns access logger and turn off its propagation it seems to work.

import logging as log
app = ...
...

log.getLogger('uvicorn.access').handlers = []
log.getLogger('uvicorn.access').propagate = False

from uvicorn-gunicorn-docker.

tiangolo avatar tiangolo commented on June 17, 2024

If anyone is still having issues, please try with a recent version of Uvicorn, a previous version was overriding the root logger.

from uvicorn-gunicorn-docker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.