../app/lib/my_simple_formatter.rb
class MySimpleFormatter < ActiveSupport::Logger::SimpleFormatter
def call(severity, timestamp, _progname, message)
d = {
level: severity,
datetime: timestamp.getutc,
source: 'rails',
host: 'karlovich',
log_type: 'rails_log',
message: message
}.to_json + "\n"
end
end
..app/config/environments/development.rb
Rails.application.configure do
...
# for development.log to json
## this delete rendering logs
config.action_view.logger = nil
## this allow see .log from info to emergency
config.log_level = :info
## this construct json string
config.log_formatter = MySimpleFormatter.new
end
Created
March 10, 2017 08:59
-
-
Save elvisgiv/3cb757b8fe33206c665ffce9a30d8692 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment