Skip to content

Forward logs to Logentries

Toshimitsu Takahashi edited this page Sep 27, 2017 · 8 revisions

An example

require 'rubygems'
require 'ougai'
require 'le'

LOGENTRIES_TOKEN = 'xxxx-xxxx-xxxx-xxxx-xxxxxxx'

host = Le::Host.new(LOGENTRIES_TOKEN, false, false, true, ['', 10000], '', [false, ''], nil, false)

logger = Ougai::Logger.new(host)
logger.formatter.with_newline = false
logger.debug('Debug!', custom_data: { id: 1, name: 'something' })

begin
  1 / 0
rescue => e
  logger.error('error occurred', e)
end

#logger.close # relying on at_exit handler for shutdown, do not close

Result on Logentries Web Console

LogentriesWebResult