Search code examples
rubythin

Ruby Thin log url it accesses


Is there anyway to tell ruby to log the url it got as a request in the log?

I am seeing some crashing in my app and can't pin down what url that is doing it.


Solution

  • Yes, it's absolutely possible, but how you implement it will depend on your app. If you're using a framework like Rails or Rack use their built-in logging classes (Thin hooks into Rack's logging class automatically). If it's a vanilla Ruby script then you can include Thin::Logging in your class, which will give you log, trace, debug, and log_error methods.

    As for logging the requested URL specifically, that depends entirely on your implementation.