@@ -10,8 +10,10 @@ description: |-
10
10
11
11
Accessing applications logs is critical when debugging issues, performance
12
12
problems or even for verifying the application is starting correctly. To make
13
- this as simple as possible, Nomad provides both a CLI tool and an API for
14
- accessing application logs and data files.
13
+ this as simple as possible, Nomad provides [ log
14
+ rotation] ( /docs/jobspec/index.html#log_rotation ) in the jobspec, provides a [ CLI
15
+ command] ( /docs/commands/logs.html ) and an [ API] ( /docs/http/client-fs.html#logs )
16
+ for accessing application logs and data files.
15
17
16
18
To see this in action we can just run the example job which created using `nomad
17
19
init`:
@@ -32,18 +34,15 @@ $ nomad run example.nomad
32
34
==> Evaluation "7a3b78c0" finished with status "complete"
33
35
```
34
36
35
- We can grab the allocation ID from above and use the [ ` nomad fs `
36
- command] ( /docs/commands/fs.html ) to access the applications logs. Logs are
37
- stored under the following directory structure:
38
- ` alloc/logs/<task-name>.<stdout/stderr>.<index> ` . Nomad has built in log
39
- rotation, documented in the [ Jobspec] ( /docs/jobspec/index.html#log_rotation ) .
40
- The index is a monotonically increasing number starting at zero and incremented
41
- each time the log is rotated.
37
+ We can grab the allocation ID from above and use the [ ` nomad logs `
38
+ command] ( /docs/commands/logs.html ) to access the applications logs. The ` logs `
39
+ command supports both displaying the logs as well as following logs, blocking
40
+ for more output.
42
41
43
42
Thus to access the ` stdout ` we can issue the below command:
44
43
45
44
```
46
- $ nomad fs c3c58508 alloc/logs/ redis.stdout.0
45
+ $ nomad logs c3c58508 redis
47
46
_._
48
47
_.-``__ ''-._
49
48
_.-`` `. `_. ''-._ Redis 3.2.1 (00000000/0) 64 bit
@@ -69,7 +68,11 @@ $ nomad fs c3c58508 alloc/logs/redis.stdout.0
69
68
1:M 28 Jun 19:49:30.505 * The server is now ready to accept connections on port 6379
70
69
```
71
70
72
- Replacing ` stdout ` for ` stderr ` would display the respective ` stderr ` output.
71
+ To display the ` stderr ` for the task we would run the following:
72
+
73
+ ```
74
+ $ nomad logs -stderr c3c58508 redis
75
+ ```
73
76
74
77
While this works well for quickly accessing logs, we recommend running a
75
78
log-shipper for long term storage of logs. In many cases this will not be needed
0 commit comments