1
votes

Very simple question: I'm running a simple flask app on heroku with no changes to the default logging settings. But my logs are filled with all kinds of terrible http request noise.

For example, I don't have any favicon or anything like that set up on my app. I don't need one. But every browser, of course, requests one, and so whenever I try to look at my logs, I get floods of requests with a 404 for the favicon and such. Which is totally useless information to me.

Example garbage logs (with sensitive information stripped):

2018-02-01T04:11:32.538658+00:00 heroku[router]: at=info method=GET path="/apple-touch-icon-precomposed.png" host=[MY_HOSTNAME_CENSORED] request_id=[A_UUID] fwd="[AN_IP_ADDRESS]" dyno=web.1 connect=0ms service=17ms status=404 bytes=386 protocol=https

2018-02-01T04:11:32.675406+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=[MY_HOSTNAME_CENSORED] request_id= fwd="[AN_IP_ADDRESS]" dyno=web.1 connect=0ms service=2ms status=404 bytes=386 protocol=https

I think that these logs are generated by heroku itself rather than the application (that's what the bit after the timestamp means, right?), but I can't find any documentation anywhere on how to change that.

There's an earlier related SO, but the latest relevant answer saying that you can't disable logs is from 2014---so I like to think this might have changed.

Alternatively, is there some way to instruct browsers not to request favicons and such?

2

2 Answers

2
votes

You could easily do this kind of filtering in whatever tool you are using for reading your logs.

For example, if you attach the Papertrail add-on to your Heroku app, you can easily configure it to filter out any log patterns you want, even if you are using their free plan. Such configuration is done via the Papertrail "Settings" menu, under "Filter logs".

See Log Filtering for details.

0
votes

There isn't any way to get rid of it entirely. But, if what you're really annoyed by is the router showing up when you're live tailing your logs (which is what I was annoyed by), then you can add "--source app" to the tail command to get rid of the router logs, like this:

heroku logs --tail --source app --remote whateveryounamedit

Then you'll only see logs generated by your app.