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

feat(logs): make gunicorn logs structured #17595

Merged
merged 4 commits into from
Feb 13, 2025
Merged

Conversation

JacobCoffee
Copy link
Member

What

Introduces structured logging for Gunicorn logs

before

web-1           | 192.168.107.1 - - [12/Feb/2025:16:55:43 +0000] "GET /_includes/flash-messages/ HTTP/1.1" 304 0 "http://0.0.0.0/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:135.0) Gecko/20100101 Firefox/135.0"
web-1           | 192.168.107.1 - - [12/Feb/2025:16:55:43 +0000] "GET /_includes/current-user-indicator/ HTTP/1.1" 304 0 "http://0.0.0.0/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:135.0) Gecko/20100101 Firefox/135.0"

after

web-1           | {"logger": "gunicorn.access", "level": "INFO", "event": "192.168.107.1 - - [12/Feb/2025:16:56:00 +0000] \"GET /_includes/flash-messages/ HTTP/1.1\" 304 0 \"http://0.0.0.0/\" \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:135.0) Gecko/20100101 Firefox/135.0\"", "thread": 281473568329760}
web-1           | {"logger": "gunicorn.access", "level": "INFO", "event": "192.168.107.1 - - [12/Feb/2025:16:56:00 +0000] \"GET /_includes/session-notifications/ HTTP/1.1\" 304 0 \"http://0.0.0.0/\" \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:135.0) Gecko/20100101 Firefox/135.0\"", "thread": 281473568329760}
web-1           | {"logger": "gunicorn.access", "level": "INFO", "event": "192.168.107.1 - - [12/Feb/2025:16:56:00 +0000] \"GET /_includes/current-user-indicator/ HTTP/1.1\" 304 0 \"http://0.0.0.0/\" \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:135.0) Gecko/20100101 Firefox/135.0\"", "thread": 281473568329760}

@JacobCoffee JacobCoffee marked this pull request as ready for review February 13, 2025 16:00
@JacobCoffee JacobCoffee requested a review from a team as a code owner February 13, 2025 16:00
@miketheman
Copy link
Member

Very cool! I wonder if this work can also push #16246 forward, so that we'll be able to look at logs locally better?

@JacobCoffee
Copy link
Member Author

@miketheman yeah I can work on that! reading the structured logging stinks locally

@ewdurbin
Copy link
Member

That looks rad @miketheman. I'm asking @JacobCoffee to look through other log output (celery for example) from warehouse in general to move it all to structlog initially. Once that's done, the console log option would probably be even more useful!

@ewdurbin ewdurbin merged commit a9e88cf into main Feb 13, 2025
20 checks passed
@ewdurbin ewdurbin deleted the gunicorn-logging-structured branch February 13, 2025 16:46
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.

3 participants