github.com/ncodes/nomad@v0.5.7-0.20170403112158-97adf4a74fb3/website/source/docs/job-specification/logs.html.md (about)

     1  ---
     2  layout: "docs"
     3  page_title: "logs Stanza - Job Specification"
     4  sidebar_current: "docs-job-specification-logs"
     5  description: |-
     6    The "logs" stanza configures the log rotation policy for a task's stdout and
     7    stderr. Logging is enabled by default with sane defaults. The "logs" stanza
     8    allows for finer-grained control over how Nomad handles log files.
     9  ---
    10  
    11  # `logs` Stanza
    12  
    13  <table class="table table-bordered table-striped">
    14    <tr>
    15      <th width="120">Placement</th>
    16      <td>
    17        <code>job -> group -> task -> **logs**</code>
    18      </td>
    19    </tr>
    20  </table>
    21  
    22  The `logs` stanza configures the log rotation policy for a task's `stdout` and
    23  `stderr`. Logging is enabled by default with sane defaults (provided in the
    24  parameters section below), and there is currently no way to disable logging for
    25  tasks. The `logs` stanza allows for finer-grained control over how Nomad handles
    26  log files.
    27  
    28  ```hcl
    29  job "docs" {
    30    group "example" {
    31      task "server" {
    32        logs {
    33          max_files     = 10
    34          max_file_size = 10
    35        }
    36      }
    37    }
    38  }
    39  ```
    40  
    41  For information on how to interact with logs after they have been configured, please see the [`nomad logs`][logs-command] command.
    42  
    43  ## `logs` Parameters
    44  
    45  - `max_files` `(int: 10)` - Specifies the maximum number of rotated files Nomad
    46    will retain for `stdout` and `stderr`. Each stream is tracked individually, so
    47    specifying a value of 2 will create 4 files - 2 for stdout and 2 for stderr
    48  
    49  - `max_file_size` `(int: 10)` - Specifies the maximum size of each rotated file
    50    in `MB`. If the amount of disk resource requested for the task is less than
    51    the total amount of disk space needed to retain the rotated set of files,
    52    Nomad will return a validation error when a job is submitted.
    53  
    54  ## `logs` Examples
    55  
    56  The following examples only show the `logs` stanzas. Remember that the
    57  `logs` stanza is only valid in the placements listed above.
    58  
    59  ### Configure Defaults
    60  
    61  This example shows a default logging configuration. Yes, it is empty on purpose.
    62  Nomad automatically enables logging with sane defaults as described in the
    63  parameters section above.
    64  
    65  ```hcl
    66  ```
    67  
    68  ### Customization
    69  
    70  This example asks Nomad to retain 3 rotated files for each of `stderr` and
    71  `stdout`, each a maximum size of 5MB per file. The minimum disk space this
    72  would require is 60MB (3 `stderr` &plus; 3 `stdout` &times; 5MB &equals; 30MB).
    73  
    74  ```hcl
    75  logs {
    76    max_files     = 3
    77    max_file_size = 5
    78  }
    79  ```
    80  
    81  [logs-command]: /docs/commands/logs.html "Nomad logs command"