Logging for debugging

135 views
Skip to first unread message

Chris Johnson

unread,
Jul 31, 2012, 6:42:23 PM7/31/12
to rack-...@googlegroups.com
Hi,

I'm simply trying to configure a *very* simple Rack app to enable logging to a file so I can tell what's going on when I exercise the app. I am using Grape (gem) within a basic Rack app to build an API, and I can't tell what is going on. I've spent over an hour, and yet cannot find ANYTHING on how to configure a logger inside Rack to log text to a file. 

I'll also say that I'm mounting the Rack app inside a Rails app, and so I need to be able to log to a file so I can tell how it's behaving within Rails. I don't necessarily need to have the two apps (Rails and Rack) logging to the same file.

Any help would be greatly appreciated.

Chris

Anurag Priyam

unread,
Aug 1, 2012, 9:59:48 AM8/1/12
to rack-...@googlegroups.com
On Wed, Aug 1, 2012 at 4:12 AM, Chris Johnson <wchris...@gmail.com> wrote:
> I'm simply trying to configure a *very* simple Rack app to enable logging to
> a file so I can tell what's going on when I exercise the app. I am using
> Grape (gem) within a basic Rack app to build an API, and I can't tell what
> is going on. I've spent over an hour, and yet cannot find ANYTHING on how to
> configure a logger inside Rack to log text to a file.

What is this Rack app logging? If the app is using a compliant
middleware to log, for example, HTTP requests, setting
'rack.errors'[1] to a File object should work.

If you are looking to log your own actions in the app, `Logger` class
from Ruby's standard library is probably what you need. You can use
`Rack::CommonLogger` (`enable :logger` in Sinatra) to log HTTP
requests in common log format.

[1]: http://rack.rubyforge.org/doc/SPEC.html

--
Anurag Priyam
Reply all
Reply to author
Forward
0 new messages