github.com/adityamillind98/nomad@v0.11.8/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-session 54 $ nomad alloc logs eb17e557 redis 55 foobar 56 baz 57 bam 58 59 $ nomad alloc logs -stderr eb17e557 redis 60 [ERR]: foo 61 [ERR]: bar 62 63 $ nomad alloc logs -job example 64 [ERR]: foo 65 [ERR]: bar 66 67 $ nomad alloc logs -tail -n 2 eb17e557 redis 68 foobar 69 baz 70 71 $ nomad alloc logs -tail -f -n 3 eb17e557 redis 72 foobar 73 baz 74 bam 75 <blocking> 76 ``` 77 78 ## Using Job ID instead of Allocation ID 79 80 Setting the `-job` flag causes a random allocation of the specified job to be 81 selected. Nomad will prefer to select a running allocation ID for the job, but 82 if no running allocations for the job are found, Nomad will use a dead 83 allocation. 84 85 ```plaintext 86 nomad alloc logs -job <job-id> <task> 87 ``` 88 89 Choosing a specific allocation is useful for debugging issues with a specific 90 instance of a service. For other operations using the `-job` flag may be more 91 convenient than looking up an allocation ID to use.