This gem helps you to quick analyse your server logs without external monitor servers. Simple applications with a low number of requests cause only a low number of errors. So you can call a cronjob to analyse your logs periodly. If the summary is not empty your server will email you the result automaticly.
Add this line to your application's Gemfile:
gem 'rails_log_parser'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install rails_log_parser
Sets your server log path:
RailsLogParser::Parser.log_path = Rails.root.join('log/production.log')
Call the rake tasks in cronjobs:
LOG_PATH=/srv/rails/log/production.log
0,20,40 * * * * rake rails_log_parser:parse[22]' # summary of the last 22 minutes
Or use it in your code:
parser = RailsLogParser::Parser.from_file(log_path)
puts parser.actions.select(&:fatal?).map(&:headline)
parser = RailsLogParser::Parser.from_file(log_path)
print parser.summary(last_minutes: 22) # print summary for the last 22 minutes
You can configure filters:
# config/rails_log_parser.rb
RailsLogParser.configure do |parser|
parser.ignore_lines = [
/Error performing MailerConfigurationJob .+ Net::ReadTimeout/,
]
end
- Known exceptions given with maximum severity
- Adding
ActionDispatch::Http::MimeNegotiation::InvalidType
as known exceptions - Update dependencies
- Remove heuristic
- Fix last action handling
- Filter lines by config file
- Better empty lines handling
- Better empty lines handling
- Adding
ActionController::UnknownFormat
as known exceptions
- Increase minimum requests value for heuristic
- Ignore periods with too few requests
- Message not parseable lines only once a day
- Delete old heuristic stat files automaticly
- Adding
ActionController::UnfilteredParameters
as known exceptions - Adjust heuristic rate for better matching
- Remove empty lines on summary without report
- Adding heuristic to rate known exceptions
- Removing
URI::InvalidURIError
as known exceptions
- Handle stacktrace of fatals too
- Adding
URI::InvalidURIError
as known exceptions
- Adding
ActionController::InvalidAuthenticityToken
as known exceptions
Bug reports and pull requests are welcome on GitHub at https://github.com/Lichtbit/rails_log_parser.
The gem is available as open source under the terms of the MIT License.