If you haven't already done so, you have to install the logworm gem first:
$ sudo gem install logworm_amqp
logworm works as a Heroku add-on; add it to your application in the same way that you install other add-ons:
$ cd <yourapp>
$ heroku addons:add logworm
This will create a logworm project for you, and set a configuration variable in your Heroku application.
If you're running Rails 2.3.4 or 2.3.8
Edit environment.rb and add
config.gem 'logworm_amqp'
inside the Rails::Initializer.run block.
If you're running Rails 3.0.0
Add gem 'logworm_amqp' to Gemfile
Edit config/application.rb and add
config.middleware.use(Logworm::Rack)
inside the class Application < Rails::Application block.
If you're running a Rack-based framework
Edit your config.ru file and indicate that you want to use logworm's Rack middleware. For example, for a Sinatra application you'd have:
$ cat config.ru
require "myapp"
require "logworm_amqp"
use Logworm::Rack
run Sinatra::Application
This basic setup will automatically log basic information about each HTTP request that your application receives. To test this, start your application locally in production mode (logworm doesn't record any data in development mode, to keep your logs clean, unless you specify that in the configuration) and visit a couple of pages; the client will start sending logging information to our servers. There is a command-line application that lets you tail those logs:
$ ./script/server -e production
[...]
$ lw-tail web_log
2010-03-02 @ 15:39:38 GMT ==>
_request_id: "23949566400260-1267544378088"
_ts_utc: 1267544378089
input: "table=sales&keys%5B%5D=customer&values%5B%5D=keith&keys%5B%5D=total&values%5B%5D=100&keys%5B%5D=&values%5B%5D="
profiling: 0.000613
queue_size: "-1"
request_ip: "24.63.134.228"
request_method: "POST"
request_path: "/post"
response_status: 200
summary: "POST /post - 200 0.000613"
2010-03-02 @ 15:39:40 GMT ==>
_request_id: "23949566400260-1267544380865"
_ts_utc: 1267544380866
input: ""
profiling: 0.00056
queue_size: "-1"
request_ip: "24.63.134.228, 10.242.45.203"
request_method: "GET"
request_path: "/favicon.ico"
response_status: 404
summary: "GET /favicon.ico - 404 0.00056"
Make sure you're running your app in production!.
When you're ready to push to Heroku, don't forget to add the 'logworm_amqp' gem to your .gems file:
$ echo 'logworm_amqp' >> .gems
$ git add .
$ git commit -m "Added logworm logging!"
$ git push heroku master