-
Notifications
You must be signed in to change notification settings - Fork 24
Forward logs to Loggly
Toshimitsu Takahashi edited this page Sep 27, 2017
·
1 revision
- Use
gem 'logglier'
freeformz/logglier - Use
Logglier::Client
directly, notLogglier
, specified Client contructor arguments are the same.
- Browse https://.loggly.com/sources/setup/ruby-app-setup
- Find new endpoint URL the 1st argument of
Logglier.new
in the last section of Step 1 - Set the URL to LOGGLY_URL in the following code
require 'rubygems'
require 'ougai'
require 'logglier'
LOGGLY_URL = "https://logs-01.loggly.com/inputs/[TOKEN]/tag/ruby/"
logger = Ougai::Logger.new(STDOUT)
loggly_client = Logglier::Client.new(LOGGLY_URL, threaded: true)
logger.extend Ougai::Logger.broadcast(Ougai::Logger.new(loggly_client))
logger.debug('Debugging', data_id: 1, data_flag: true)
begin
raise StandardError, 'fatal error'
rescue => ex
logger.fatal('Unexpected!', ex)
end
logger.info({
msg: 'Request', method: 'GET', path: '/login',
format: 'html', controller: 'LoginController',
action: 'new', status: 200
})
A Logger outputs to STDOUT with forwarding to Loggly.