# Get task logs


[API catalog](/reference/api/) · [Docker Engine overview](/reference/api/engine/version/v1.57/) · [Product manual](https://docs.docker.com/engine/) · [OpenAPI specification](/reference/api/engine/version/v1.57.yaml)

API version: 1.57





`GET /tasks/{id}/logs`

Get `stdout` and `stderr` logs from a task.
See also [`/containers/{id}/logs`](/reference/api/engine/version/v1.57/operations/ContainerLogs/).

**Note**: This endpoint works only for services with the `local`,
`json-file` or `journald` logging drivers.


## Connection and access

[API connection and authentication guidance](/reference/api/engine/version/v1.57/#connection)


Server: `/v1.57`

Effective security: alternatives are OR; schemes within an alternative are AND. An empty array declares no HTTP authentication requirement.

```json
null
```

## Example request

Replace placeholders and provide the required credentials or request body.

```console
curl \
  --request GET \
  --unix-socket "${DOCKER_SOCKET:-/var/run/docker.sock}" \
  --header 'Accept: application/vnd.docker.multiplexed-stream' \
  'http://localhost/v1.57/tasks/<ID>/logs'
```



## Parameters

### id

Location: path. Required: yes.

ID of the task

```json
{
  "description": "ID of the task",
  "in": "path",
  "name": "id",
  "pointer": "/paths/~1tasks~1{id}~1logs/get/parameters/0",
  "required": true,
  "schema": {
    "type": "string"
  }
}
```

### details

Location: query. Required: no.

Show task context and extra details provided to logs.

```json
{
  "description": "Show task context and extra details provided to logs.",
  "in": "query",
  "name": "details",
  "pointer": "/paths/~1tasks~1{id}~1logs/get/parameters/1",
  "schema": {
    "default": false,
    "type": "boolean"
  }
}
```

### follow

Location: query. Required: no.

Keep connection after returning logs.

```json
{
  "description": "Keep connection after returning logs.",
  "in": "query",
  "name": "follow",
  "pointer": "/paths/~1tasks~1{id}~1logs/get/parameters/2",
  "schema": {
    "default": false,
    "type": "boolean"
  }
}
```

### stdout

Location: query. Required: no.

Return logs from `stdout`

```json
{
  "description": "Return logs from `stdout`",
  "in": "query",
  "name": "stdout",
  "pointer": "/paths/~1tasks~1{id}~1logs/get/parameters/3",
  "schema": {
    "default": false,
    "type": "boolean"
  }
}
```

### stderr

Location: query. Required: no.

Return logs from `stderr`

```json
{
  "description": "Return logs from `stderr`",
  "in": "query",
  "name": "stderr",
  "pointer": "/paths/~1tasks~1{id}~1logs/get/parameters/4",
  "schema": {
    "default": false,
    "type": "boolean"
  }
}
```

### since

Location: query. Required: no.

Only return logs since this time, as a UNIX timestamp

```json
{
  "description": "Only return logs since this time, as a UNIX timestamp",
  "in": "query",
  "name": "since",
  "pointer": "/paths/~1tasks~1{id}~1logs/get/parameters/5",
  "schema": {
    "default": 0,
    "type": "integer"
  }
}
```

### timestamps

Location: query. Required: no.

Add timestamps to every log line

```json
{
  "description": "Add timestamps to every log line",
  "in": "query",
  "name": "timestamps",
  "pointer": "/paths/~1tasks~1{id}~1logs/get/parameters/6",
  "schema": {
    "default": false,
    "type": "boolean"
  }
}
```

### tail

Location: query. Required: no.

Only return this number of log lines from the end of the logs.
Specify as an integer or `all` to output all log lines.


```json
{
  "description": "Only return this number of log lines from the end of the logs.\nSpecify as an integer or `all` to output all log lines.\n",
  "in": "query",
  "name": "tail",
  "pointer": "/paths/~1tasks~1{id}~1logs/get/parameters/7",
  "schema": {
    "default": "all",
    "type": "string"
  }
}
```

## Request and responses

### Response 200 application/vnd.docker.multiplexed-stream

logs returned as a stream in response body


Schema:

```json
{
  "format": "binary",
  "type": "string"
}
```










### Response 200 application/vnd.docker.raw-stream

logs returned as a stream in response body


Schema:

```json
{
  "format": "binary",
  "type": "string"
}
```










### Response 404 application/json

no such task


Schema:

```json
{
  "$ref": "#/components/schemas/ErrorResponse"
}
```









Example:
```json
{
  "message": "No such task: c2ada9df5af8"
}
```


### Response 500 application/json

server error


Schema:

```json
{
  "$ref": "#/components/schemas/ErrorResponse"
}
```









Schema example:
```json
{
  "message": "Something went wrong."
}
```


### Response 503 application/json

node is not part of a swarm


Schema:

```json
{
  "$ref": "#/components/schemas/ErrorResponse"
}
```









Schema example:
```json
{
  "message": "Something went wrong."
}
```


## Complete operation contract

```json
{
  "description": "Get `stdout` and `stderr` logs from a task.\nSee also [`/containers/{id}/logs`](#operation/ContainerLogs).\n\n**Note**: This endpoint works only for services with the `local`,\n`json-file` or `journald` logging drivers.\n",
  "operationId": "TaskLogs",
  "parameters": [
    {
      "description": "ID of the task",
      "in": "path",
      "name": "id",
      "required": true,
      "schema": {
        "type": "string"
      }
    },
    {
      "description": "Show task context and extra details provided to logs.",
      "in": "query",
      "name": "details",
      "schema": {
        "default": false,
        "type": "boolean"
      }
    },
    {
      "description": "Keep connection after returning logs.",
      "in": "query",
      "name": "follow",
      "schema": {
        "default": false,
        "type": "boolean"
      }
    },
    {
      "description": "Return logs from `stdout`",
      "in": "query",
      "name": "stdout",
      "schema": {
        "default": false,
        "type": "boolean"
      }
    },
    {
      "description": "Return logs from `stderr`",
      "in": "query",
      "name": "stderr",
      "schema": {
        "default": false,
        "type": "boolean"
      }
    },
    {
      "description": "Only return logs since this time, as a UNIX timestamp",
      "in": "query",
      "name": "since",
      "schema": {
        "default": 0,
        "type": "integer"
      }
    },
    {
      "description": "Add timestamps to every log line",
      "in": "query",
      "name": "timestamps",
      "schema": {
        "default": false,
        "type": "boolean"
      }
    },
    {
      "description": "Only return this number of log lines from the end of the logs.\nSpecify as an integer or `all` to output all log lines.\n",
      "in": "query",
      "name": "tail",
      "schema": {
        "default": "all",
        "type": "string"
      }
    }
  ],
  "responses": {
    "200": {
      "content": {
        "application/vnd.docker.multiplexed-stream": {
          "schema": {
            "format": "binary",
            "type": "string"
          }
        },
        "application/vnd.docker.raw-stream": {
          "schema": {
            "format": "binary",
            "type": "string"
          }
        }
      },
      "description": "logs returned as a stream in response body"
    },
    "404": {
      "content": {
        "application/json": {
          "example": {
            "message": "No such task: c2ada9df5af8"
          },
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "no such task"
    },
    "500": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "server error"
    },
    "503": {
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ErrorResponse"
          }
        }
      },
      "description": "node is not part of a swarm"
    }
  },
  "summary": "Get task logs",
  "tags": [
    "Task"
  ]
}
```

## Referenced schemas

- [#/components/schemas/ErrorResponse](/reference/api/engine/version/v1.57/schemas/ErrorResponse/)




