(alternate Post Title: My First Gem, please be gentle)
Filtering rails logs is like trying eat soup with a fork in space while going through a black hole. Ok, not that bad, but it takes some work.
Why would you want to filter logs by IP?
- Load balancers: My production boxes at work get pounded by the load balancers to make sure they are there. All that activity fills up our rails logs with repetitive noise that’s useless. useless. useless. It would be great to remove those log entries.
- Low volume side projects: My side projects have very low volumes, but I still want them snappy and responsive when they get that 15th hit for the day at 11pm. So I have cron jobs which hit my side project sites on a regular basis. Again, this fills my logs with noise.
Distilled gem allows you to filter out rails logs by IP. Its pretty easy to setup, just install the gem, and create a one line initializer to set the IP addresses.
SampleApp::Application.config.middleware.swap( Rails::Rack::Logger, Distilled::DistilledLogger, :filtered_ips => ['123.456.789.1', '127.0.0.1'] )