# Retrieve logs of a specific connection

`GET /api/2/connections/{connectionId}/logs`

Returns the logs of the connection identified by the `connectionId` path parameter.
**Before** log entries are generated and returned, logging needs be enabled with the `command`
`connectivity.commands:enableConnectionLogs`. When creating or opening an connection the logging is enabled per
default. This allows to log possible errors on connection establishing.

Authentication (security requirement alternatives):

```json
[
  {
    "DevOpsBasic": []
  },
  {
    "DevOpsBearer": []
  }
]
```

- DevOpsBasic: http (basic). Eclipse Ditto devops user (devops) + password (foobar)
- DevOpsBearer: http (bearer). A JSON Web Token issued by a supported OAuth 2.0 Identity Provider for the Eclipse Ditto devops user.

Parameters:

- `connectionId` (path, string, required) - The ID of the connection
  Type: string

Responses:

- 200: The request successfully returned the connection logs.

Content type: application/json

Type: ConnectionLogs

Log entries of a connection.

Schema: [ConnectionLogs](https://sourcey-ditto.pages.dev/http-api-doc/models/connectionlogs.md)

- `connectionId` (required)
  Type: string
  
  ID of the connection for which the log entries were logged.
  
  Example:
  
  ```json
  "759304b8-8056-11e9-bc42-526af7764f64"
  ```

- `connectionLogs` (required)
  Type: Array<LogEntry>
  
  Log entries for the connection.
  
  Items:
    Reference: [LogEntry](https://sourcey-ditto.pages.dev/http-api-doc/models/logentry.md); Type: LogEntry
    
    Represents a log entry for a connection.

- `enabledSince` (optional)
  Type: string
  
  Since when logging is enabled. Might be missing / null if logging is not enabled.
  
  Example:
  
  ```json
  "2019-01-21T08:57:24.710Z"
  ```

- `enabledUntil` (optional)
  Type: string
  
  Until when logging is enabled. Might be missing / null if logging is not enabled.
  
  Example:
  
  ```json
  "2019-01-22T08:57:24.710Z"
  ```

- 400: The request could not be completed. The `connectionId` must be an URI.

Content type: application/json

Type: AdvancedError

Schema: [AdvancedError](https://sourcey-ditto.pages.dev/http-api-doc/models/advancederror.md)

- `status` (required)
  Type: integer
  
  The HTTP status of the error

- `error` (required)
  Type: string
  
  The error code of the occurred exception

- `message` (required)
  Type: string
  
  The message of the error - what went wrong

- `description` (optional)
  Type: string
  
  A description how to fix the error or more details

- `href` (optional)
  Type: string
  
  A link to further information about the error and how to fix it

- 401: The request could not be completed due to missing authentication.

Content type: application/json

Type: AdvancedError

Schema: [AdvancedError](https://sourcey-ditto.pages.dev/http-api-doc/models/advancederror.md)

- `status` (required)
  Type: integer
  
  The HTTP status of the error

- `error` (required)
  Type: string
  
  The error code of the occurred exception

- `message` (required)
  Type: string
  
  The message of the error - what went wrong

- `description` (optional)
  Type: string
  
  A description how to fix the error or more details

- `href` (optional)
  Type: string
  
  A link to further information about the error and how to fix it

- 403: The request could not be completed due to invalid authentication.

Content type: application/json

Type: AdvancedError

Schema: [AdvancedError](https://sourcey-ditto.pages.dev/http-api-doc/models/advancederror.md)

- `status` (required)
  Type: integer
  
  The HTTP status of the error

- `error` (required)
  Type: string
  
  The error code of the occurred exception

- `message` (required)
  Type: string
  
  The message of the error - what went wrong

- `description` (optional)
  Type: string
  
  A description how to fix the error or more details

- `href` (optional)
  Type: string
  
  A link to further information about the error and how to fix it

- 404: The request could not be completed. The connection with ID `connectionId` was not found.

Content type: application/json

Type: AdvancedError

Schema: [AdvancedError](https://sourcey-ditto.pages.dev/http-api-doc/models/advancederror.md)

- `status` (required)
  Type: integer
  
  The HTTP status of the error

- `error` (required)
  Type: string
  
  The error code of the occurred exception

- `message` (required)
  Type: string
  
  The message of the error - what went wrong

- `description` (optional)
  Type: string
  
  A description how to fix the error or more details

- `href` (optional)
  Type: string
  
  A link to further information about the error and how to fix it

## Examples

### cURL

```bash
curl -X GET 'https://ditto.eclipseprojects.io/api/2/connections/string/logs' \
  -H 'Authorization: Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE'
```

### JavaScript

```javascript
const response = await fetch('https://ditto.eclipseprojects.io/api/2/connections/string/logs', {
  method: 'GET',
  headers: {
    'Authorization': 'Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE',
  },
});

const data = await response.text();
```

### Python

```python
import requests

response = requests.get(
    'https://ditto.eclipseprojects.io/api/2/connections/string/logs',
    headers={
        'Authorization': 'Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE',
    },
)
print(response.text)
```
