1
2
3
4
5
6
7
8
9
10
11
12
13
|
<h1>docker service logs</h1> <p><br></p> <p>Fetch the logs of a service or task</p> <p><span class="badge badge-info" data-toggle="tooltip" data-placement="right" title="This command works with the Swarm orchestrator.">Swarm</span> This command works with the Swarm orchestrator.</p> <h2 id="usage">Usage</h2> <div class="highlight"><pre class="highlight" data-language="">$ docker service logs [OPTIONS] SERVICE|TASK
</pre></div> <p>Refer to the <a href="#options">options section</a> for an overview of available <a href="#options"><code class="language-plaintext highlighter-rouge">OPTIONS</code></a> for this command.</p> <h2 id="description">Description</h2> <p name="extended-description">The <code class="language-plaintext highlighter-rouge">docker service logs</code> command batch-retrieves logs present at the time of execution.</p> <blockquote> <p><strong>Note</strong></p> <p>This is a cluster management command, and must be executed on a swarm manager node. To learn about managers and workers, refer to the <a href="../../../swarm/index">Swarm mode section</a> in the documentation.</p> </blockquote> <p>The <code class="language-plaintext highlighter-rouge">docker service logs</code> command can be used with either the name or ID of a service, or with the ID of a task. If a service is passed, it will display logs for all of the containers in that service. If a task is passed, it will only display logs from that particular task.</p> <blockquote> <p><strong>Note</strong></p> <p>This command is only functional for services that are started with the <code class="language-plaintext highlighter-rouge">json-file</code> or <code class="language-plaintext highlighter-rouge">journald</code> logging driver.</p> </blockquote> <p>For more information about selecting and configuring logging drivers, refer to <a href="https://docs.docker.com/config/containers/logging/configure/">Configure logging drivers</a>.</p> <p>The <code class="language-plaintext highlighter-rouge">docker service logs --follow</code> command will continue streaming the new output from the service’s <code class="language-plaintext highlighter-rouge">STDOUT</code> and <code class="language-plaintext highlighter-rouge">STDERR</code>.</p> <p>Passing a negative number or a non-integer to <code class="language-plaintext highlighter-rouge">--tail</code> is invalid and the value is set to <code class="language-plaintext highlighter-rouge">all</code> in that case.</p> <p>The <code class="language-plaintext highlighter-rouge">docker service logs --timestamps</code> command will add an <a href="https://golang.org/pkg/time/#pkg-constants">RFC3339Nano timestamp</a> , for example <code class="language-plaintext highlighter-rouge">2014-09-16T06:17:46.000000000Z</code>, to each log entry. To ensure that the timestamps are aligned the nano-second part of the timestamp will be padded with zero when necessary.</p> <p>The <code class="language-plaintext highlighter-rouge">docker service logs --details</code> command will add on extra attributes, such as environment variables and labels, provided to <code class="language-plaintext highlighter-rouge">--log-opt</code> when creating the service.</p> <p>The <code class="language-plaintext highlighter-rouge">--since</code> option shows only the service logs generated after a given date. You can specify the date as an RFC 3339 date, a UNIX timestamp, or a Go duration string (e.g. <code class="language-plaintext highlighter-rouge">1m30s</code>, <code class="language-plaintext highlighter-rouge">3h</code>). Besides RFC3339 date format you may also use RFC3339Nano, <code class="language-plaintext highlighter-rouge">2006-01-02T15:04:05</code>, <code class="language-plaintext highlighter-rouge">2006-01-02T15:04:05.999999999</code>, <code class="language-plaintext highlighter-rouge">2006-01-02Z07:00</code>, and <code class="language-plaintext highlighter-rouge">2006-01-02</code>. The local timezone on the client will be used if you do not provide either a <code class="language-plaintext highlighter-rouge">Z</code> or a <code class="language-plaintext highlighter-rouge">+-00:00</code> timezone offset at the end of the timestamp. When providing Unix timestamps enter seconds[.nanoseconds], where seconds is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap seconds (aka Unix epoch or Unix time), and the optional .nanoseconds field is a fraction of a second no more than nine digits long. You can combine the <code class="language-plaintext highlighter-rouge">--since</code> option with either or both of the <code class="language-plaintext highlighter-rouge">--follow</code> or <code class="language-plaintext highlighter-rouge">--tail</code> options.</p> <h2 id="options">Options</h2> <table> <thead> <tr> <td>Name, shorthand</td> <td>Default</td> <td>Description</td> </tr> </thead> <tbody> <tr> <td><code class="language-plaintext highlighter-rouge">--details</code></td> <td></td> <td>Show extra details provided to logs</td> </tr> <tr> <td>
<code class="language-plaintext highlighter-rouge">--follow</code> , <code class="language-plaintext highlighter-rouge">-f</code>
</td> <td></td> <td>Follow log output</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--no-resolve</code></td> <td></td> <td>Do not map IDs to Names in output</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--no-task-ids</code></td> <td></td> <td>Do not include task IDs in output</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--no-trunc</code></td> <td></td> <td>Do not truncate output</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--raw</code></td> <td></td> <td>Do not neatly format logs</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--since</code></td> <td></td> <td>Show logs since timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)</td> </tr> <tr> <td>
<code class="language-plaintext highlighter-rouge">--tail</code> , <code class="language-plaintext highlighter-rouge">-n</code>
</td> <td><code class="language-plaintext highlighter-rouge">all</code></td> <td>Number of lines to show from the end of the logs</td> </tr> <tr> <td>
<code class="language-plaintext highlighter-rouge">--timestamps</code> , <code class="language-plaintext highlighter-rouge">-t</code>
</td> <td></td> <td>Show timestamps</td> </tr> </tbody> </table> <h2 id="parent-command">Parent command</h2> <table> <thead> <tr> <th style="text-align: left">Command</th> <th style="text-align: left">Description</th> </tr> </thead> <tbody> <tr> <td style="text-align: left"><a href="../service/index">docker service</a></td> <td style="text-align: left">Manage services</td> </tr> </tbody> </table> <h2 id="related-commands">Related commands</h2> <table> <thead> <tr> <td>Command</td> <td>Description</td> </tr> </thead> <tbody> <tr> <td><a href="../service_create/index">docker service create</a></td> <td>Create a new service</td> </tr> <tr> <td><a href="../service_inspect/index">docker service inspect</a></td> <td>Display detailed information on one or more services</td> </tr> <tr> <td><a href="index">docker service logs</a></td> <td>Fetch the logs of a service or task</td> </tr> <tr> <td><a href="../service_ls/index">docker service ls</a></td> <td>List services</td> </tr> <tr> <td><a href="../service_ps/index">docker service ps</a></td> <td>List the tasks of one or more services</td> </tr> <tr> <td><a href="../service_rm/index">docker service rm</a></td> <td>Remove one or more services</td> </tr> <tr> <td><a href="../service_rollback/index">docker service rollback</a></td> <td>Revert changes to a service’s configuration</td> </tr> <tr> <td><a href="../service_scale/index">docker service scale</a></td> <td>Scale one or multiple replicated services</td> </tr> <tr> <td><a href="../service_update/index">docker service update</a></td> <td>Update a service</td> </tr> </tbody> </table> <div class="_attribution">
<p class="_attribution-p">
© 2019 Docker, Inc.<br>Licensed under the Apache License, Version 2.0.<br>Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. in the United States and/or other countries.<br>Docker, Inc. and other parties may also have trademark rights in other terms used herein.<br>
<a href="https://docs.docker.com/engine/reference/commandline/service_logs/" class="_attribution-link">https://docs.docker.com/engine/reference/commandline/service_logs/</a>
</p>
</div>
|