How to disable Rails RoutingError stacktrace printout in Production log files?

前端 未结 2 1655
长发绾君心
长发绾君心 2021-02-13 05:15

In my proudction rails app, I got all types of random attacks requesting for asp, zip and rar files. Rails rendered 404 page as expected, but my production log file is jammed wi

2条回答
  •  别那么骄傲
    2021-02-13 05:18

    You could add a catch all route after all your other routes that would catch this stuff and render a controller/action of your choosing:

    match '*' => 'errors#not_found'
    

    You could even choose to only match .asp or whatever if you wanted:

    match '*.:format' => 'errors#not_found', :constraints => {:format => /(asp|zip|rar)/i}
    

提交回复
热议问题