Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mute ActiveStorage Logs

ActiveStorage floods my dev logs so i'm drowning in requests for images on a page. Is there a way to mute active storage or atleast reduce the log entries so that I can use my logs again?

For example, for each of the images on a page that are accessed via ActiveStorage, I get one of these:

2018-09-03 11:07:42.181697 I [75455:70130232359340 log_subscriber.rb:12] (2.365ms) ActiveStorage::DiskController -- Completed #show -- {
        :controller => "ActiveStorage::DiskController",
            :action => "show",
            :params => {
        "content_type" => "image/jpeg",
         "disposition" => "inline; filename=\"faded-flip.jpg\"; filename*=UTF-8''faded-flip.jpg",
         "encoded_key" => "eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaEpJbk4yWVhKcFlXNTBjeTh6TnpRMVlqSmtZaTB3WlRCakxUUTVaRFV0WW1Ga01DMWxNRFl4TWpFd09Ua3dOMkl2TkdRME1qQTBNR1EzTjJaaE5UZ3pOVFU1WXpSbVpqaGlOVFpoWVdVd01ESmhabVJqWW1GaE5HTmxPRFV3WXpneU1UUmhPVEpsWlRVNVl6bGlPRGs0WVFZNkJrVlUiLCJleHAiOiIyMDE4LTA5LTAzVDEwOjEyOjMyLjUwN1oiLCJwdXIiOiJibG9iX2tleSJ9fQ==--b9eed7f4cf3d71fcb697429188e1a1a74ba88bec",
            "filename" => "faded-flip"
    },
            :format => "JPEG",
            :method => "GET",
              :path => "/rails/active_storage/disk/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaEpJbk4yWVhKcFlXNTBjeTh6TnpRMVlqSmtZaTB3WlRCakxUUTVaRFV0WW1Ga01DMWxNRFl4TWpFd09Ua3dOMkl2TkdRME1qQTBNR1EzTjJaaE5UZ3pOVFU1WXpSbVpqaGlOVFpoWVdVd01ESmhabVJqWW1GaE5HTmxPRFV3WXpneU1UUmhPVEpsWlRVNVl6bGlPRGs0WVFZNkJrVlUiLCJleHAiOiIyMDE4LTA5LTAzVDEwOjEyOjMyLjUwN1oiLCJwdXIiOiJibG9iX2tleSJ9fQ==--b9eed7f4cf3d71fcb697429188e1a1a74ba88bec/faded-flip.jpg",
            :status => 200,
      :view_runtime => 0.69,
        :db_runtime => 0.0,
    :status_message => "OK"
}
127.0.0.1 - - [03/Sep/2018:11:07:41 BST] "GET /rails/active_storage/disk/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaEpJbk4yWVhKcFlXNTBjeTh6TnpRMVlqSmtZaTB3WlRCakxUUTVaRFV0WW1Ga01DMWxNRFl4TWpFd09Ua3dOMkl2TkdRME1qQTBNR1EzTjJaaE5UZ3pOVFU1WXpSbVpqaGlOVFpoWVdVd01ESmhabVJqWW1GaE5HTmxPRFV3WXpneU1UUmhPVEpsWlRVNVl6bGlPRGs0WVFZNkJrVlUiLCJleHAiOiIyMDE4LTA5LTAzVDEwOjEyOjMyLjUwN1oiLCJwdXIiOiJibG9iX2tleSJ9fQ==--b9eed7f4cf3d71fcb697429188e1a1a74ba88bec/faded-flip.jpg?content_type=image%2Fjpeg&disposition=inline%3B+filename%3D%22faded-flip.jpg%22%3B+filename%2A%3DUTF-8%27%27faded-flip.jpg HTTP/1.1" 200 21345
http://localhost:3000/users/password/new -> /rails/active_storage/disk/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaEpJbk4yWVhKcFlXNTBjeTh6TnpRMVlqSmtZaTB3WlRCakxUUTVaRFV0WW1Ga01DMWxNRFl4TWpFd09Ua3dOMkl2TkdRME1qQTBNR1EzTjJaaE5UZ3pOVFU1WXpSbVpqaGlOVFpoWVdVd01ESmhabVJqWW1GaE5HTmxPRFV3WXpneU1UUmhPVEpsWlRVNVl6bGlPRGs0WVFZNkJrVlUiLCJleHAiOiIyMDE4LTA5LTAzVDEwOjEyOjMyLjUwN1oiLCJwdXIiOiJibG9iX2tleSJ9fQ==--b9eed7f4cf3d71fcb697429188e1a1a74ba88bec/faded-flip.jpg?content_type=image%2Fjpeg&disposition=inline%3B+filename%3D%22faded-flip.jpg%22%3B+filename%2A%3DUTF-8%27%27faded-flip.jpg
2018-09-03 11:07:42.234412 D [75455:70130203086520 log_subscriber.rb:8] ActiveStorage::DiskController -- Processing #show
2018-09-03 11:07:42.239153 I [75455:70130203086520 log_subscriber.rb:96] Rails --   FlatDisk Storage (0.1ms) Downloaded file from key: variants/ef6bca1d-bfd1-485e-b7cd-88a0e1e95404/4d42040d77fa583559c4ff8b56aae002afdcbaa4ce850c8214a92ee59c9b898a

Any help would be greatly appreciated. :)

like image 560
Paul Danelli Avatar asked Sep 03 '18 10:09

Paul Danelli


2 Answers

I'm using Lograge Gem to hide those requests.

config.lograge.ignore_actions = [
  "ActiveStorage::DiskController#show",
  "ActiveStorage::RepresentationsController#show"
]
like image 118
Archer Avatar answered Sep 28 '22 04:09

Archer


According to the article of EvilMartians I've set

config.active_record.verbose_query_logs option to false inside application.rb.

It partly solves the problem.

It seems like Active Storage people consider the most verbose logging very important. So now logs about files take the same size on the disk as stored files.

And the most irritating thing is the level of these messages is INFO. I can't understand why it's not DEBUG...

like image 26
Alexander Gorg Avatar answered Sep 28 '22 06:09

Alexander Gorg