github.com/hspak/nomad@v0.7.2-0.20180309000617-bc4ae22a39a5/website/source/docs/commands/logs.html.md.erb (about)

     1  ---
     2  layout: "docs"
     3  page_title: "Commands: logs"
     4  sidebar_current: "docs-commands-logs"
     5  description: >
     6    Stream the logs of a task.
     7  ---
     8  
     9  # Command: logs
    10  
    11  The `logs` command displays the log of a given task.
    12  
    13  ## Usage
    14  
    15  ```
    16  nomad logs [options] <allocation> <task>
    17  ```
    18  
    19  This command streams the logs of the given task in the allocation. If the
    20  allocation is only running a single task, the task name can be omitted.
    21  Optionally, the `-job` option may be used in which case a random allocation from
    22  the given job will be chosen.
    23  #
    24  ## General Options
    25  
    26  <%= partial "docs/commands/_general_options" %>
    27  
    28  ## Logs Options
    29  
    30  * `-stderr`: Display stderr logs.
    31  
    32  * `-verbose`: Display verbose output.
    33  
    34  * `-job`: Use a random allocation from the specified job, preferring a running
    35  allocation.
    36  
    37  * `-f`: Causes the output to not stop when the end of the logs are reached, but
    38  rather to wait for additional output.
    39  
    40  * `-tail`: Show the logs contents with offsets relative to the end of the logs.
    41  If no offset is given, -n is defaulted to 10.
    42  
    43  * `-n`: Sets the tail location in best-efforted number of lines relative to the
    44  end of the logs.
    45  
    46  * `-c`: Sets the tail location in number of bytes relative to the end of the logs.
    47  
    48  ## Examples
    49  
    50  ```
    51  $ nomad logs eb17e557 redis
    52  foobar
    53  baz
    54  bam
    55  
    56  $ nomad logs -stderr eb17e557 redis
    57  [ERR]: foo
    58  [ERR]: bar
    59  
    60  $ nomad logs -job example
    61  [ERR]: foo
    62  [ERR]: bar
    63  
    64  $ nomad logs -tail -n 2 eb17e557 redis
    65  foobar
    66  baz
    67  
    68  $ nomad logs -tail -f -n 3 eb17e557 redis
    69  foobar
    70  baz
    71  bam
    72  <blocking>
    73  ```
    74  
    75  ## Using Job ID instead of Allocation ID
    76  
    77  Setting the `-job` flag causes a random allocation of the specified job to be
    78  selected. Nomad will prefer to select a running allocation ID for the job, but
    79  if no running allocations for the job are found, Nomad will use a dead
    80  allocation.
    81  
    82  ```
    83  nomad logs -job <job-id> <task>
    84  ```
    85  
    86  
    87  This can be useful for debugging a job that has multiple allocations, and it's
    88  not really required to use a specific allocation ID.