Configuration Reference Template
Settings reference – precedence rules, file format, per-key type/default/range/env var/since, deprecations, validation
使用方法: Use when a product has more than a handful of settings. State precedence first, then fill one complete row per key, ideally generated from the schema. The main pitfall is empty defaults and undocumented deprecated keys.
预览
Configuration Reference: [Product name] [version]
Complete list of the settings that control [Product name], how they are loaded and how they are validated. Based on common industry practice for configuration reference documentation. Replace every
[bracketed]value and every row marked Example.
| Field | Value |
|---|---|
| Product version | [4.2.0] |
| Configuration schema version | [3] |
| Owner | [@platform-team] |
| Status | [Draft / Approved] |
| Last updated | YYYY-MM-DD |
1. Sources and precedence
[Product name] reads configuration from four sources. When the same setting is defined in more than one place, the source higher in this list wins:
| Rank | Source | Example | Notes |
|---|---|---|---|
| 1 (highest) | Command-line flag | --server.port=9090 | Applies to this process only |
| 2 | Environment variable | APP_SERVER_PORT=9090 | Prefix APP_, dots become underscores, upper case |
| 3 | Configuration file | server.port: 9090 | First file found, see 2 |
| 4 (lowest) | Built-in default | 8080 | Listed in the tables below |
To see the effective value and where it came from, run
[app] config show --origin. Secrets are masked in the output.
2. File location and format
The first file found in this order is used; others are ignored:
- The path in
--configorAPP_CONFIG. ./app.yamlin the working directory./etc/app/app.yaml(Windows:%ProgramData%\App\app.yaml).
YAML 1.2 and TOML 1.0 are supported; the format is chosen from the file extension. Unknown keys are rejected so that typos are not silently ignored. A complete example with defaults:
schema_version: 3
server:
host: 0.0.0.0
port: 8080
request_timeout: 30s
database:
url: ${DATABASE_URL}
max_connections: 20
cache:
enabled: true
ttl: 5m
logging:
level: info
format: json
${NAME} is replaced with the value of environment variable NAME at
load time; a missing variable is a validation error.
3. Value types
| Type | Format | Examples |
|---|---|---|
| string | UTF-8 text | "eu-west-1" |
| integer | Whole number, optional _ separators | 20, 10_000 |
| boolean | true or false (also 1/0 in environment variables) | true |
| duration | Number with unit ms, s, m, h | 500ms, 30s, 5m |
| size | Number with unit B, KB, MB, GB (base 1024) | 64MB |
| enum | One of the listed values, case-sensitive | info |
| secret | String that is masked in logs and output | ${DATABASE_URL} |
4. Settings
4.1 server
| Key | Type | Default | Allowed values | Environment variable | Description | Since |
|---|---|---|---|---|---|---|
server.host | string | 0.0.0.0 | IPv4 or IPv6 address | APP_SERVER_HOST | Interface to listen on | 1.0 |
server.port | integer | 8080 | 1 to 65535 | APP_SERVER_PORT | TCP port for HTTP traffic | 1.0 |
server.request_timeout | duration | 30s | 1s to 10m | APP_SERVER_REQUEST_TIMEOUT | Maximum time to handle one request | 2.1 |
server.max_body_size | size | 10MB | 1KB to 1GB | APP_SERVER_MAX_BODY_SIZE | Largest accepted request body | 3.0 |
4.2 database
| Key | Type | Default | Allowed values | Environment variable | Description | Since |
|---|---|---|---|---|---|---|
database.url | secret | none (required) | postgres:// URL | APP_DATABASE_URL | Connection string including credentials | 1.0 |
database.max_connections | integer | 20 | 1 to 500 | APP_DATABASE_MAX_CONNECTIONS | Pool size per process | 1.0 |
database.statement_timeout | duration | 15s | 100ms to 5m | APP_DATABASE_STATEMENT_TIMEOUT | Cancels slower queries | 3.2 |
4.3 cache
| Key | Type | Default | Allowed values | Environment variable | Description | Since |
|---|---|---|---|---|---|---|
cache.enabled | boolean | true | true, false | APP_CACHE_ENABLED | Turns the response cache on or off | 2.0 |
cache.ttl | duration | 5m | 0s to 24h | APP_CACHE_TTL | Time an entry stays valid; 0s disables expiry | 2.0 |
cache.max_size | size | 256MB | 16MB to 16GB | APP_CACHE_MAX_SIZE | Memory limit for the cache | 4.0 |
4.4 logging
| Key | Type | Default | Allowed values | Environment variable | Description | Since |
|---|---|---|---|---|---|---|
logging.level | enum | info | debug, info, warn, error | APP_LOGGING_LEVEL | Minimum severity written | 1.0 |
logging.format | enum | json | json, text | APP_LOGGING_FORMAT | Output format | 1.4 |
| [key] | [type] | [default] | [allowed] | [ENV_VAR] | [Description] | [x.y] |
5. Changes at runtime
Settings marked with a reload flag in config show --origin can be
changed without restarting: edit the file and send SIGHUP or call
POST /admin/reload. Currently reloadable: logging.level,
cache.ttl, server.request_timeout. All other changes need a restart.
6. Deprecated and removed settings
| Key | Status | Replacement | Deprecated in | Removed in | Behaviour now |
|---|---|---|---|---|---|
db.pool | Removed | database.max_connections | 2.0 | 4.0 | Startup error |
server.timeout | Deprecated | server.request_timeout | 3.0 | [5.0] | Value used, warning logged |
cache.size_mb | Deprecated | cache.max_size | 4.0 | [5.0] | Converted, warning logged |
| [old key] | [Deprecated / Removed] | [new key] | [x.y] | [x.y] | [Behaviour] |
7. Validation
Configuration is validated at startup and on every reload. An invalid configuration stops startup; an invalid reload is rejected and the running configuration stays in place. Run the same checks before deploying:
app config validate --config ./app.yaml
Checks performed:
- Every key is known for the declared
schema_version. - Every value has the right type and is inside its allowed range.
- Required settings without defaults are present.
- Referenced environment variables exist.
- Cross-field rules hold, for example
the
database server's connection limit (checked when
--instancesis given).
Example error output (exit status 2):
app.yaml:7:20 database.max_connections: 900 is above the maximum of 500
app.yaml:12:10 logging.level: "verbose" is not one of debug, info, warn, error
8. Related documents
- [Installation Guide]: where the file is created during setup.
- [Administrator Guide]: recommended production values and tuning.
- [Changelog]: settings added, changed or deprecated per release.
Standard and licence note
Based on common industry practice for configuration reference documentation, including layered precedence of flags, environment variables, files and defaults. Template licence: MIT.
相关模板
CLI Reference Template (Man Page Sections)
Command-line reference in man-page order – synopsis, options, commands, environment, files, exit status, examples
文档与支持Reference Documentation Template (Diataxis)
Diátaxis reference page – neutral, consistently structured entries for functions, types, errors and constants
文档与支持Administrator Guide Template (ISO/IEC/IEEE 26514)
Admin guide – roles, architecture, access, backup/restore, monitoring, maintenance, scaling, security ops, DR, audit