github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/website/pages/docs/commands/alloc/logs.mdx (about)

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