Giter VIP home page Giter VIP logo

le_ruby's Introduction

Logging to Logentries in Ruby

This is a Logentries library for logging from Ruby platforms, including Heroku.

It is available on github https://github.com/logentries/le_ruby/ and rubygems http://rubygems.org/.

Example

Rails.logger.info("information message")
Rails.logger.warn("warning message")
Rails.logger.debug("debug message")

Howto

You must first register your account details with Logentries.

Once you have logged in to Logentries, create a new host with a name of your choice. Inside this host, create a new logfile, selecting Token TCP as the source type.

Heroku

To install the gem you must edit the Gemfile in your local heroku environment

Add the following line:

gem 'le'

Then from the cmd line run the following command:

bundle install

This will install the gem on your local environment.

The next step is to configure the default rails logger to use the logentries logger.

In your environment configuration file ( for production : config/environments/production.rb), add the following:

Rails.logger = Le.new('LOGENTRIES_TOKEN')

If you want to keep also the logs in the console and in the log file just add true after the key:

Rails.logger = Le.new('LOGENTRIES_TOKEN', true)

You can also specify the default level of the logger by adding this :

Rails.logger = Le.new('LOGENTRIES_TOKEN', true, Logger::<level>)

This will set the rails logger to use the Logentries logger in production and log to the console in development environment.

For the LOGENTRIES_TOKEN argument, paste the token for the logfile you created earlier in the Logentries UI.

Now, simply use Rails.logger.info("message") inside your code to send logs to Logentries

le_ruby's People

Contributors

joshnesbitt avatar marklc-r7 avatar tgautier avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.