This guide provides step-by-step instructions on how to send logs from a Ruby on Rails app to Axiom using the Faraday library.
rbenv
and use it to install the latest Ruby version.gem install rails
command.rails new myapp
command.
cd myapp
Gemfile
in your Rails app, and then add the following gems:
bundle install
.
axiom_logger.rb
in the app/services
directory of your Rails app.
axiom_logger.rb
:
API_TOKEN
with the Axiom API token you have generated. For added security, store the API token in an environment variable.Replace DATASET_NAME
with the name of the Axiom dataset where you send your data.Replace AXIOM_DOMAIN
with api.axiom.co
if your organization uses the US region, and with api.eu.axiom.co
if your organization uses the EU region. For more information, see Regions.axiom_logger_test.rb
in the config/initializers
directory.
axiom_logger_test.rb
:
log.rake
taskstasks
in the lib
directory of your Rails app.log.rake
in the lib/tasks
directory.log.rake
:rails server
.
http://localhost:3000
to trigger the test log from the initializer.
rails log:send_test_log
in your terminal.