PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, July 15, 2022

[FIXED] How do I suppress http request logs on heroku (using flask, if it matters)?

 July 15, 2022     heroku, web-deployment     No comments   

Issue

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?


Solution

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.



Answered By - Yoni Rabinovitch
Answer Checked By - Willingham (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing