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