[Awesome Ruby Gem] Use rails_semantic_logger gem to replaces the Rails default logger
rails_semantic_logger
Semantic Logger is a comprehensive Rails logging interface that enables human and machine readable logging outputs.
-
Colorful text log files for humans to read.
-
JSON log files containing all Semantic information that machines can easily comsume.
-
Write to multiple output destinations at the same time.
-
Forward logs to a centralized logging system, via JSON output or built-in appenders.
Installation
You can install it as a gem:
1 | gem install amazing_print |
or add it into a Gemfile (Bundler):
1 | # Gemfile |
Then, run bundle install
.
1 | bundle install |
This will automatically replace the standard Rails logger with Semantic Logger which will write all log data to the configured Rails log file.
Conflicting Gems
Remove all of the following gems since they conflict or duplicate what Rails Semantic Logger already achieves.
-
lograge
-
rails_stdout_logging
-
rails_12factor
Configuration
1 | # config/initializers/semantic_logger.rb |
Usage
Example:
1 | require 'semantic_logger' |
Informational logging
1 | logger.info("Calling Supplier") |
Error information
1 | logger.error("Oops external call failed", :result => :failed, :reason_code => -10) |