You can use the Logglier library to send Ruby logs to Loggly. It can send Ruby on Rails logs over HTTP/S to Loggly and accepts multiline and JSON events. For alternatives, please see the Advanced Options section below.
Ruby Logging Setup
1. Install Logglier
Open Gemfile in your application. It should be present in the root directory of your application.
Add the following statement to the Gemfile to include the logglier gem in your application
gem 'logglier', '~> 0.2.11'
Install the gem using bundle
Add the following code in your
<environment>.rb config file. You can find it in the config/environments folder present in your application directory structure. You can select .rb file on the basis of your current environment setup. It can be development.rb, test.rb or production.rb
require 'logglier' config.logger = Logglier.new("https://logs-01.loggly.com/inputs/TOKEN/tag/ruby/", :threaded => true)
- TOKEN: your customer token from the source setup page
2. Send a Test Event
Now use the logger in your application.
logger.info("Beavers signal an alarm by slapping the water with their tail.")
Restart your rails application and visit a page so that it sends this event to Loggly.
3. Verify Events
Search Loggly for events with the ruby tag over the past 20 minutes. It may take a few minutes to index the event. If it doesn’t work, see the troubleshooting section below.
Advanced Ruby Logging Options
- Logglier GitHub – Additional options for Rails syslog, TLS, and more.
- Rails Logging – Instructions specific for Rails logging with Loggly.
- Loggly Libraries Catalog – See more options of sending Ruby Logs to Loggly.
- Logging Fast – If speed is a concern, then you should pick a fast transport protocol. Here is their speed ranking from fastest to slowest:
- Syslog UDP
- Syslog TCP
- Threaded HTTP
- Threaded HTTPS
- Blocking HTTP
- Blocking HTTPS
Syslog is the fastest because it’s the most efficient protocol and the syslog daemon runs asynchronously with it’s own queuing system (and optionally TLS encryption).
UDP uses a simple connectionless transmission model with a minimum of protocol mechanism. There is no guarantee of delivery, ordering, or duplicate protection.
Threaded won’t block your app but it can use up more memory and stack space. Blocking is the slowest because your app will wait for the data to be received by Loggly.
HTTPS is slower than HTTP because it requires an extra round trip to setup the secure connection.
Troubleshooting Ruby Logs
- Wait a few minutes in case indexing needs to catch up.
- See if you have included the correct version of Logglier.
- See our HTTP Troubleshooting Guide to verify HTTP events are being sent to Loggly.
- Search or post your own Ruby logging or Ruby on Rails logging questions in the community forum.
When the APM Integrated Experience is enabled, Loggly shares a common navigation and settings with the other integrated experiences' products. How you navigate Loggly and access its features may vary from these instructions. For more information, go to the APM Integrated Experience documentation.
The scripts are not supported under any SolarWinds support program or service. The scripts are provided AS IS without warranty of any kind. SolarWinds further disclaims all warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The risk arising out of the use or performance of the scripts and documentation stays with you. In no event shall SolarWinds or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the scripts or documentation.