Created
October 6, 2016 10:03
-
-
Save mpugach/a5cb68f9664fc481cbf63b9ad2f25e07 to your computer and use it in GitHub Desktop.
Rails + Fluentd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
common: &common | |
tag: 'my.mega.tag' | |
fluent_host: 'my.mega.host' | |
fluent_port: 24225 | |
severity_key: 'level' | |
messages_type: 'string' | |
production: | |
<<: *common |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'act-fluent-logger-rails' | |
gem 'lograge' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config.logger = ActFluentLoggerRails::Logger.new | |
config.log_tags = [:request_id] | |
config.log_level = :info | |
config.lograge.enabled = true | |
config.lograge.formatter = Lograge::Formatters::Json.new | |
config.middleware.delete ActionDispatch::DebugExceptions | |
config.lograge.custom_options = lambda do |event| | |
payload = { params: event.payload[:params].except('controller', 'action', 'format') } | |
payload[:host] = Rails.application.secrets.hostname | |
exception_object = event.payload[:exception_object] | |
payload[:backtrace] = exception_object.backtrace.join("\n") unless exception_object.blank? | |
payload | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment