logstasher-logger gem
# Step 1: Add the logstasher-logger gem to your Gemfile
gem 'logstasher-logger', '~> 0.1.1'
# Step 2: Run bundle install to install the gem
bundle install
# Step 3: Configure logstasher-logger in your application, typically in an initializer
# config/initializers/logstasher.rb
LogStasher::Logger.configure do |config|
config.enabled = true
# Add any other configuration options as needed
end
# Step 4: Optionally, configure LogStasher settings in your application for additional customization
# config/application.rb or an initializer
config.logstasher.enabled = true
config.logstasher.suppress_app_log = false
config.logstasher.source = 'your_application_name'
config.logstasher.backtrace = true
# Step 5: Use the LogStasher logger in your application code
logger = LogStasher.logger
logger.info('Your log message here')
# Step 6: Optionally, log additional fields with your messages
logger.info('Your log message here', custom_field: 'custom_value')
# Step 7: Start your application and check the log output for LogStasher-formatted logs
# Log entries will be in JSON format, including timestamp, log level, message, and any additional fields
Make sure to adapt the configuration options according to your specific needs.