title: Logging in Sinatra?
body: <p>I'm having trouble figuring out how to log messages with Sinatra. I'm not looking to log requests, but rather custom messages at certain points in my app. For example, when fetching a URL I would like to log <code>"Fetching #{url}"</code>.</p>
  
  <p>Here's what I'd like:</p>
  
  <ul>
  <li>The ability to specify log levels (ex: <code>logger.info("Fetching #{url}")</code>)</li>
  <li>In development and testing environments, the messages would be written to the console.</li>
  <li>In production, only write out messages matching the current log level.</li>
  </ul>
  
  <p>I'm guessing this can easily be done in <code>config.ru</code>, but I'm not 100% sure which setting I want to enable, and if I have to manually create a <code>Logger</code> object myself (and furthermore, which class of <code>Logger</code> to use: <code>Logger</code>, <code>Rack::Logger</code>, or <code>Rack::CommonLogger</code>).</p>
  
  <p>(I know there are similar questions on StackOverflow, but none seem to directly answer my question. If you can point me to an existing question, I will mark this one as a duplicate).</p>