Random Notes

Filter uWSGI Logs Based on Path

I was wondering today how to filter uWSGI logs based on the request path because we had an endpoint that was filling our logs with meaningless information. At least for me this was surprisingly difficult to find. So here is an example command line option:

--log-filter '^((?!/api/foo/bar).)*$'

The log-filter flag takes in a regular expression that is used to include lines that match the filter (so it works as a whitelist). To filter lines that don’t contain something, you can use a negative lookahead.