Update log docs

Matt Holt 2019-10-28 14:51:35 -06:00
parent 97eaae2861
commit 3d28dcbc68

@ -463,6 +463,8 @@ All contexts support the global placeholders:
The system's architecture
{system.slash}
The system's filepath separator
{time.now.common_log}
The current timestamp in Common Log Format
{env.variable_name}
Replace variable_name with any env variable (lowercase)
```
@ -665,7 +667,7 @@ That single line is sufficient and works for _most_ PHP scripts (replace `php-fp
If you have a Unix socket, use an address in the form `unix//path/to/socket`.
This directive actually has the same syntax and options as [reverse_proxy](#reverse_proxy), but is shorthand for a configuration equivalent to this example (do not needlessly copy and paste this example; the directive above is recommended unless you need more fine-grained customization):
This directive actually has the same syntax and options as [reverse_proxy](#reverse_proxy), but is shorthand for a configuration equivalent to this example (**PLEASE do not needlessly copy and paste this example**, because the directive above does the same thing and is recommended unless your specific needs are different):
```
# canonicalize URI trailing slash when index file present
@ -856,7 +858,11 @@ Configures the administration endpoint.
## logging
Configures Caddy logs.
Configures Caddy logs. By default, all logs at INFO level and higher are written to standard error ("stderr" writer) in a human-readable format ("console" encoder). The default log is called "default" and you can customize it. You can also define additional logs.
By default, all logs accept all log entries, but you can filter by level and module/logger names. A logger's name is the same as the module's name, but a module may append to logger names for more specificity. For example, you can filter only logs emitted by HTTP handlers using the name `"http.handlers"`, because all HTTP handler module names start with that.
There is also a "sink" where all unstructured logs emitted from Go's standard library logger are written. These logs are common in dependencies that are not designed specifically for use in Caddy. Because they are unstructured and global, the sink lacks most advanced features and customizations.
```json
{
@ -892,7 +898,7 @@ Configures Caddy logs.
- `logs.default.sampling.first`: Log this many entries within a given level and message for each interval.
- `logs.default.sampling.thereafter`: If more entries with the same level and message are seen during the same interval, keep one in this many entries until the end of the interval.
- `logs.default.include`: Allow modules within this namespace to emit logs here. Mutually exclusive with `exclude`.
- `logs.default.exlucde`: Deny modules within this namespace from emitting logs here. Mutually exclusive with `include`.
- `logs.default.exclude`: Deny modules within this namespace from emitting logs here. Mutually exclusive with `include`.
If both `include` and `exclude` are populated, longer namespaces have priority. If neither are populated, all logs are emitted.
@ -922,7 +928,7 @@ Emits logs to standard error. This is the default writer.
#### caddy.logging.writers.discard
Discards all writes. This effectively disables the log, and is only useful if you want to turn off the default log.
Discards all writes. This effectively disables the log, and is only useful if you want to completely turn off the default log.
```json
{
@ -990,7 +996,7 @@ In addition to the properties specific to each encoder, these properties are ava
#### caddy.logging.encoders.console
Formats log enties for human readability on the console.
Formats log enties for human readability on the console. This is the default encoder.
```json
{
@ -1042,7 +1048,7 @@ This filter masks IP addresses.
#### caddy.logging.encoders.json
JSON formatted logs. There is one JSON document per line/entry. This is the default encoder.
JSON formatted logs. There is one JSON document per line/entry.
```json
{
@ -1074,7 +1080,7 @@ An encoder that will write an entry that consists exclusively of a single field
```
- `field`: The name of the field to use its value as the log entry.
- `fallback`: An encoder to use if the specified field does not exist or cannot be used. Note that this can lead to mixed encodings in your log file.
- `fallback`: An encoder to use if the specified field does not exist or cannot be used. Note that this can lead to mixed encodings in your log file, but depending on your requirements, may be better than eliding log entries entirely.
## storage
@ -1148,7 +1154,10 @@ A map of server ID (of your choice) to its configuration object. Each server is
"automatic_https": {},
"max_rehandles": 3,
"strict_sni_host": false,
"experimental_http3": false
"experimental_http3": false,
"logs": {
"logger_names": {}
},
}
```
@ -1165,6 +1174,8 @@ A map of server ID (of your choice) to its configuration object. Each server is
- `max_rehandles`: How many rehandles to allow; prevents infinite looping.
- `strict_sni_host`: If true, enforce that an HTTP Host header matches the connection's ServerName (SNI) value from the TLS handshake. Important when using TLS client authentication.
- `experimental_http3`: If true, IETF-draft-compliant HTTP/3 ("QUIC") will be enabled. It creates a UDP listener. This feature is experimental and is not subject to compatibility promises.
- `logs`: Enables and configures HTTP access and error logging. An empty object uses default settings. Access logs document HTTP requests as they come in; they use the namespace `http.log.access`. Error logs record HTTP handler errors and use the namespace `http.log.error`.
- `logs.logger_names`: Map of request host to custom logger name. For example, if you wanted all requests for `example.com` to be emitted to a logger with a unique name, you can do `"example.com": "example"` and then all access logs related to requests for `example.com` will use a logger named `http.log.access.example` (and same for error logs, but with `.error.` in the name instead).
#### http/servers/listen
@ -1959,7 +1970,7 @@ Transport modules:
}
```
- `tls`: Configures TLS between the proxy and the backend.
- `tls`: Enables and configures TLS between the proxy and the backend. An empty object will use secure defaults.
- `tls.root_ca_pool`: A list of base64-encoded DER certificates to use as the root CA pool; these are the CA certificates that will be accepted by the proxy when connecting to a backend with TLS.
- `tls.client_certificate_file`: Path to a PEM certificate file to present to the backend. For use with TLS client authentication (mTLS, i.e. for the proxy to authenticate with the backend).
- `tls.client_certificate_key_file`: Path to the PEM private key file associated with the client certificate in `client_certificate_file`.