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

How do i disable logging for specific path #30

Closed
Delvify opened this issue Aug 8, 2021 · 1 comment
Closed

How do i disable logging for specific path #30

Delvify opened this issue Aug 8, 2021 · 1 comment

Comments

@Delvify
Copy link

Delvify commented Aug 8, 2021

I am using PrometheusMiddleware from starlette_prometheus
ever second or the, it keeps generating log, this grows the log file.

How do i disable this log, this specific?

INFO:     127.0.0.1:57304 - "GET /metrics HTTP/1.1" 200 OK
INFO:     127.0.0.1:57310 - "GET /metrics HTTP/1.1" 200 OK
INFO:     127.0.0.1:57304 - "GET /metrics HTTP/1.1" 200 OK
INFO:     127.0.0.1:57310 - "GET /metrics HTTP/1.1" 200 OK
INFO:     127.0.0.1:57304 - "GET /metrics HTTP/1.1" 200 OK
INFO:     127.0.0.1:57310 - "GET /metrics HTTP/1.1" 200 OK
INFO:     127.0.0.1:57304 - "GET /metrics HTTP/1.1" 200 OK
INFO:     127.0.0.1:57310 - "GET /metrics HTTP/1.1" 200 OK
............several  million times .............................
INFO:     127.0.0.1:57310 - "GET /metrics HTTP/1.1" 200 OK
@celloni
Copy link

celloni commented Oct 16, 2021

Hey @Delvify
The log is not generated by PrometheusMiddleware. You could achieve this by using a log filter.

// example with uvicorn
logger = logging.getLogger('uvicorn.access')
logger.addFilter(lambda record: 'GET /metrics' not in record.getMessage())

@perdy perdy closed this as completed Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants