ConciseLogging
Concise request logging for Rails production
Logs a concise single line for each request at :warn
level. This allows
logging requests without all the extra logging that :info
level outputs.
Not suitable for development but ideal for production settings where each request and associated parameters is logged.
Inspired by a blog post on RubyJunky.com.
Special thanks to Zohreh Jabbari for doing the initial coding and proof of concept.
Installation
Add this line to your application's Gemfile:
gem 'concise_logging'
And then execute:
$ bundle
Or install it yourself as:
$ gem install concise_logging
Usage
Add this to your config/production.rb
. Configure tagging as per your desires.
We use tagging to indicate application with a 2 letter code and environment with
a single letter (e.g., p = production, s = staging).
# Configure logger to log warn and above
config.log_level = :warn
config.log_tags = ["cv-#{Rails.env[0]}"]
config.logger = ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(File.join(Rails.root, "log", "#{Rails.env}.log")))
If you want to try the logger in development than you have to manually add the
middleware and attach the log subscriber by adding these lines in your
config/development.rb
file. These lines are not needed for production.
Rails.application.middleware.use ConciseLogging::LogMiddleware
ConciseLogging::LogSubscriber.attach_to :action_controller
Contributing
- Fork it ( https://github.com/[my-github-username]/concise_logging/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request