---
title: Sinatra
description: Gather Sinatra application logs.
breadcrumbs: Docs > Integrations > Sinatra
---

# Sinatra
Supported OS 
## Overview{% #overview %}

This integration enables you to get web access logging from your [Sinatra](http://sinatrarb.com) applications in order to monitor:

- Errors logs (4xx codes, 5xx codes)
- Web pages response time
- Number of requests
- Number of bytes exchanged

## Setup{% #setup %}

### Installation{% #installation %}

[Install the Agent](https://app.datadoghq.com/account/settings/agent/latest) on the instance that runs your Sinatra application.

### Configuration{% #configuration %}

The default [Sinatra logging](http://sinatrarb.com/intro.html#Logging) feature logs to stdout. Datadog recommends that you use the [Rack](http://rack.github.io) [Common Logger](https://www.rubydoc.info/github/rack/rack/Rack/CommonLogger) in order to log to a file and in the console.

Here is a configuration example that generate logs in a file and the console. This can be set in the Rack configuration file (`config.ru`) or the configuration block for your Sinatra application.

```ruby
require 'sinatra'

configure do
  # logging is enabled by default in classic style applications,
  # so `enable :logging` is not needed
  file = File.new("/var/log/sinatra/access.log", 'a+')
  file.sync = true
  use Rack::CommonLogger, file
end

get '/' do
  'Hello World'
end
```

This logger uses the common Apache Access format and generates logs in the following format:

```text
127.0.0.1 - - [15/Jul/2018:17:41:40 +0000] "GET /uptime_status HTTP/1.1" 200 34 0.0004
127.0.0.1 - - [15/Jul/2018 23:40:31] "GET /uptime_status HTTP/1.1" 200 6997 1.8096
```

#### Log collection{% #log-collection %}

*Available for Agent versions >6.0*

1. Collecting logs is disabled by default in the Datadog Agent. Enable it in your `datadog.yaml` file with:

   ```yaml
   logs_enabled: true
   ```

1. Add this configuration block to your `sinatra.d/conf.yaml` file at the root of your [Agent's configuration directory](https://docs.datadoghq.com/agent/guide/agent-configuration-files/#agent-configuration-directory) to start collecting your Sinatra application logs:

   ```yaml
   logs:
     - type: file
       path: /var/log/sinatra/access.log
       source: sinatra
       service: webapp
   ```

Change the `path` and `service` parameter values and configure them for your environment.

1. [Restart the Agent](https://docs.datadoghq.com/agent/guide/agent-commands/#restart-the-agent)
