...

Text file src/github.com/docker/cli/docs/reference/commandline/service_logs.md

Documentation: github.com/docker/cli/docs/reference/commandline

     1# service logs
     2
     3<!---MARKER_GEN_START-->
     4Fetch the logs of a service or task
     5
     6### Options
     7
     8| Name                 | Type     | Default | Description                                                                                     |
     9|:---------------------|:---------|:--------|:------------------------------------------------------------------------------------------------|
    10| `--details`          |          |         | Show extra details provided to logs                                                             |
    11| `-f`, `--follow`     |          |         | Follow log output                                                                               |
    12| `--no-resolve`       |          |         | Do not map IDs to Names in output                                                               |
    13| `--no-task-ids`      |          |         | Do not include task IDs in output                                                               |
    14| `--no-trunc`         |          |         | Do not truncate output                                                                          |
    15| `--raw`              |          |         | Do not neatly format logs                                                                       |
    16| `--since`            | `string` |         | Show logs since timestamp (e.g. `2013-01-02T13:23:37Z`) or relative (e.g. `42m` for 42 minutes) |
    17| `-n`, `--tail`       | `string` | `all`   | Number of lines to show from the end of the logs                                                |
    18| `-t`, `--timestamps` |          |         | Show timestamps                                                                                 |
    19
    20
    21<!---MARKER_GEN_END-->
    22
    23## Description
    24
    25The `docker service logs` command batch-retrieves logs present at the time of execution.
    26
    27> **Note**
    28>
    29> This is a cluster management command, and must be executed on a swarm
    30> manager node. To learn about managers and workers, refer to the
    31> [Swarm mode section](https://docs.docker.com/engine/swarm/) in the
    32> documentation.
    33
    34The `docker service logs` command can be used with either the name or ID of a
    35service, or with the ID of a task. If a service is passed, it will display logs
    36for all of the containers in that service. If a task is passed, it will only
    37display logs from that particular task.
    38
    39> **Note**
    40>
    41> This command is only functional for services that are started with
    42> the `json-file` or `journald` logging driver.
    43
    44For more information about selecting and configuring logging drivers, refer to
    45[Configure logging drivers](https://docs.docker.com/config/containers/logging/configure/).
    46
    47The `docker service logs --follow` command will continue streaming the new output from
    48the service's `STDOUT` and `STDERR`.
    49
    50Passing a negative number or a non-integer to `--tail` is invalid and the
    51value is set to `all` in that case.
    52
    53The `docker service logs --timestamps` command will add an [RFC3339Nano timestamp](https://pkg.go.dev/time#RFC3339Nano)
    54, for example `2014-09-16T06:17:46.000000000Z`, to each
    55log entry. To ensure that the timestamps are aligned the
    56nano-second part of the timestamp will be padded with zero when necessary.
    57
    58The `docker service logs --details` command will add on extra attributes, such as
    59environment variables and labels, provided to `--log-opt` when creating the
    60service.
    61
    62The `--since` option shows only the service logs generated after
    63a given date. You can specify the date as an RFC 3339 date, a UNIX
    64timestamp, or a Go duration string (e.g. `1m30s`, `3h`). Besides RFC3339 date
    65format you may also use RFC3339Nano, `2006-01-02T15:04:05`,
    66`2006-01-02T15:04:05.999999999`, `2006-01-02Z07:00`, and `2006-01-02`. The local
    67timezone on the client will be used if you do not provide either a `Z` or a
    68`+-00:00` timezone offset at the end of the timestamp. When providing Unix
    69timestamps enter seconds[.nanoseconds], where seconds is the number of seconds
    70that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap
    71seconds (aka Unix epoch or Unix time), and the optional .nanoseconds field is a
    72fraction of a second no more than nine digits long. You can combine the
    73`--since` option with either or both of the `--follow` or `--tail` options.
    74
    75## Related commands
    76
    77* [service create](service_create.md)
    78* [service inspect](service_inspect.md)
    79* [service ls](service_ls.md)
    80* [service ps](service_ps.md)
    81* [service rm](service_rm.md)
    82* [service rollback](service_rollback.md)
    83* [service scale](service_scale.md)
    84* [service update](service_update.md)

View as plain text