Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--access-logformat STRING not working #2382

Closed
KlausGlueckert opened this issue Jul 15, 2020 · 6 comments
Closed

--access-logformat STRING not working #2382

KlausGlueckert opened this issue Jul 15, 2020 · 6 comments

Comments

@KlausGlueckert
Copy link

KlausGlueckert commented Jul 15, 2020

When using https://github.com/tiangolo/uvicorn-gunicorn-fastapi-docker FastAPI, it seems the access_log format cannot be customized, neither with log-config nor with --access-logformat

-------------------start.sh--------------
#start.sh
exec gunicorn -k uvicorn.workers.UvicornWorker -c "$GUNICORN_CONF" "$APP_MODULE" --log-config "/logging.conf" --access-logformat "%(h)s %(l)s %(u)s %(t)s %(r)s %(s)s %(b)s %(f)s %(a)s"

-------------------logging.conf--------
[loggers]
keys=root, gunicorn.error, gunicorn.access,uvicorn.error,uvicorn.access

[handlers]
keys=console, error_file, access_file, accesscustom

[formatters]
keys=generic, access, AccessFormatter

[logger_root]
level=INFO
handlers=console
propagate=1

[logger_gunicorn.error]
level=INFO
handlers=error_file
propagate=0
qualname=gunicorn.error

[logger_gunicorn.access]
level=INFO
handlers=accesscustom
propagate=0
qualname=gunicorn.access

[logger_uvicorn.error]
level=INFO
handlers=error_file
propagate=0
qualname=uvicorn.error

[logger_uvicorn.access]
level=INFO
handlers=access_file
propagate=0
qualname=uvicorn.access

[handler_console]
class=StreamHandler
formatter=generic
args=(sys.stdout, )

[handler_error_file]
class=StreamHandler
formatter=generic
args=(sys.stdout, )

[handler_access_file]
class=StreamHandler
formatter=access
args=(sys.stdout, )

[handler_accesscustom]
class=StreamHandler
formatter=AccessFormatter
args=(sys.stdout, )

[formatter_generic]
format=[%(levelname)s]: %(message)s
datefmt=%Y-%m-%dT%H:%M:%S
class=logging.Formatter

[formatter_access]
format=[%(levelname)s]: %(message)s
datefmt=%Y-%m-%dT%H:%M:%S
class=logging.Formatter

[formatter_AccessFormatter]
format=[%(levelname)s]: %(message)s
datefmt=%Y-%m-%dT%H:%M:%S
class=logging.Formatter
access_log_format = %(h)s %(l)s %(u)s %(t)s %(r)s %(s)s %(b)s %(f)s %(a)s
`

@changduckGO
Copy link

I also faced this problem... Is there workaround?

@noname2048
Copy link

noname2048 commented Dec 10, 2021

This problem happens when using option -k uvicorn.workers.UvicornWorker
It seems ignore the access_log_format option.

# gunicorn.conf.py
accesslog = "./logs/gunicorn/gunicorn.access.logs"
errorlog = "./logs/gunicorn/gunicorn.error.logs"
access_log_format = "%({x-forwarded-for}i)s %(l)s %(l)s %(l)s %(l)s'"

Not Using the option (with normal worker) >>> 127.0.0.1 - - - -
Using the option (with uvicorn worker) >>> - "GET / HTTP/1.0" 200

I wonder whoes problem is this (uvicorn or gunicorn)

Related problem: #2382(this) #2299
Ok. (2299) -> It seems uvicorn has to solve this problem.

encode/uvicorn#389 >> first issued
encode/uvicorn#527 >> similar
encode/uvicorn#947 >> Implementing..?

@Kludex
Copy link

Kludex commented Jan 6, 2023

There's nothing Gunicorn can do.

@benoitc
Copy link
Owner

benoitc commented Aug 6, 2024

no activity since awhile. closing feel free to create a new ticket if needed.

@benoitc benoitc closed this as completed Aug 6, 2024
@SnoozeFreddo
Copy link

It's a Uvicorn issue then?

@Kludex
Copy link

Kludex commented Aug 25, 2024

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants