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

Configure gunicorn access log #246

Merged
merged 1 commit into from
Dec 8, 2024
Merged

Conversation

edmorley
Copy link
Member

@edmorley edmorley commented Dec 8, 2024

  • Explicitly enable the access log (since currently it's only enabled when using the classic Python buildpack, and not locally or when using the Python CNB).
  • Customise the gunicorn access log format to make it use the Heroku logfmt style, and to improve which fields are included.

Format before:

2024-12-08T16:23:33.457957+00:00 app[web.1]: ::ffff:10.1.50.245 - - [08/Dec/2024:16:23:33 +0000] "GET / HTTP/1.1" 200 9585 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:134.0) Gecko/20100101 Firefox/134.0"

Format after:

2024-12-08T16:32:47.618296+00:00 app[web.1]: gunicorn method=GET path="/" status=200 duration=14ms request_id=e45f9c86-d6d8-4b79-937e-18c0b6bf859e fwd="123.456.789.0" user_agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:134.0) Gecko/20100101 Firefox/134.0"

Ref heroku/buildpacks-python#4.
GUS-W-17316745.

* Explicitly enable the access log (since currently it's only enabled
  when using the classic Python buildpack, and not locally or when
  using the Python CNB).
* Customise the gunicorn access log format to make it use the Heroku
  logfmt style, and to improve which fields are included.

Before:

```
2024-12-08T16:23:33.457957+00:00 app[web.1]: ::ffff:10.1.50.245 - - [08/Dec/2024:16:23:33 +0000] "GET / HTTP/1.1" 200 9585 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:134.0) Gecko/20100101 Firefox/134.0"
```

After:

```
2024-12-08T16:32:47.618296+00:00 app[web.1]: gunicorn method=GET path="/" status=200 duration=14ms request_id=e45f9c86-d6d8-4b79-937e-18c0b6bf859e fwd="123.456.789.0" user_agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:134.0) Gecko/20100101 Firefox/134.0"
```
@edmorley edmorley self-assigned this Dec 8, 2024
@edmorley edmorley marked this pull request as ready for review December 8, 2024 16:41
@edmorley edmorley requested a review from a team as a code owner December 8, 2024 16:41
@edmorley edmorley removed the request for review from a team December 8, 2024 16:43
@heroku heroku bot temporarily deployed to getting-star-edmorley-g-ba6xzh December 8, 2024 16:47 Inactive
@edmorley edmorley merged commit d580c39 into main Dec 8, 2024
1 check passed
@edmorley edmorley deleted the edmorley/gunicorn-access-log branch December 8, 2024 16:48
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

Successfully merging this pull request may close these issues.

1 participant