github.com/sld880311/docker@v0.0.0-20200524143708-d5593973a475/docs/reference/commandline/service_logs.md (about)

     1  ---
     2  title: "service logs (experimental)"
     3  description: "The service logs command description and usage"
     4  keywords: "service, logs"
     5  advisory: "experimental"
     6  ---
     7  
     8  <!-- This file is maintained within the docker/docker Github
     9       repository at https://github.com/docker/docker/. Make all
    10       pull requests against that repo. If you see this file in
    11       another repository, consider it read-only there, as it will
    12       periodically be overwritten by the definitive file. Pull
    13       requests which include edits to this file in other repositories
    14       will be rejected.
    15  -->
    16  
    17  # service logs
    18  
    19  ```Markdown
    20  Usage:  docker service logs [OPTIONS] SERVICE
    21  
    22  Fetch the logs of a service
    23  
    24  Options:
    25        --details        Show extra details provided to logs
    26    -f, --follow         Follow log output
    27        --help           Print usage
    28        --since string   Show logs since timestamp
    29        --tail string    Number of lines to show from the end of the logs (default "all")
    30    -t, --timestamps     Show timestamps
    31  ```
    32  
    33  ## Description
    34  
    35  The `docker service logs` command batch-retrieves logs present at the time of execution.
    36  
    37  > **Note**: This command is only functional for services that are started with
    38  > the `json-file` or `journald` logging driver.
    39  
    40  For more information about selecting and configuring logging drivers, refer to
    41  [Configure logging drivers](https://docs.docker.com/engine/admin/logging/overview/).
    42  
    43  The `docker service logs --follow` command will continue streaming the new output from
    44  the service's `STDOUT` and `STDERR`.
    45  
    46  Passing a negative number or a non-integer to `--tail` is invalid and the
    47  value is set to `all` in that case.
    48  
    49  The `docker service logs --timestamps` command will add an [RFC3339Nano timestamp](https://golang.org/pkg/time/#pkg-constants)
    50  , for example `2014-09-16T06:17:46.000000000Z`, to each
    51  log entry. To ensure that the timestamps are aligned the
    52  nano-second part of the timestamp will be padded with zero when necessary.
    53  
    54  The `docker service logs --details` command will add on extra attributes, such as
    55  environment variables and labels, provided to `--log-opt` when creating the
    56  service.
    57  
    58  The `--since` option shows only the service logs generated after
    59  a given date. You can specify the date as an RFC 3339 date, a UNIX
    60  timestamp, or a Go duration string (e.g. `1m30s`, `3h`). Besides RFC3339 date
    61  format you may also use RFC3339Nano, `2006-01-02T15:04:05`,
    62  `2006-01-02T15:04:05.999999999`, `2006-01-02Z07:00`, and `2006-01-02`. The local
    63  timezone on the client will be used if you do not provide either a `Z` or a
    64  `+-00:00` timezone offset at the end of the timestamp. When providing Unix
    65  timestamps enter seconds[.nanoseconds], where seconds is the number of seconds
    66  that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap
    67  seconds (aka Unix epoch or Unix time), and the optional .nanoseconds field is a
    68  fraction of a second no more than nine digits long. You can combine the
    69  `--since` option with either or both of the `--follow` or `--tail` options.
    70  
    71  ## Related commands
    72  
    73  * [service create](service_create.md)
    74  * [service inspect](service_inspect.md)
    75  * [service ls](service_ls.md)
    76  * [service rm](service_rm.md)
    77  * [service scale](service_scale.md)
    78  * [service ps](service_ps.md)
    79  * [service update](service_update.md)