Merge pull request #69382 from rschu1ze/doc-from

Docs: Document per-logger level overrides
This commit is contained in:
Robert Schulze 2024-09-09 12:21:22 +00:00 committed by GitHub
commit 420bc3a072
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1463,26 +1463,29 @@ Examples:
## logger {#logger} ## logger {#logger}
Logging settings. The location and format of log messages.
Keys: Keys:
- `level` Logging level. Acceptable values: `trace`, `debug`, `information`, `warning`, `error`. - `level` Log level. Acceptable values: `none` (turn logging off), `fatal`, `critical`, `error`, `warning`, `notice`, `information`,
- `log` The log file. Contains all the entries according to `level`. `debug`, `trace`, `test`
- `errorlog` Error log file. - `log` The path to the log file.
- `size` Size of the file. Applies to `log` and `errorlog`. Once the file reaches `size`, ClickHouse archives and renames it, and creates a new log file in its place. - `errorlog` The path to the error log file.
- `count` The number of archived log files that ClickHouse stores. - `size` Rotation policy: Maximum size of the log files in bytes. Once the log file size exceeds this threshold, it is renamed and archived, and a new log file is created.
- `console` Send `log` and `errorlog` to the console instead of file. To enable, set to `1` or `true`. - `count` Rotation policy: How many historical log files Clickhouse are kept at most.
- `console_log_level` Logging level for console. Default to `level`. - `stream_compress` Compress log messages using LZ4. Set to `1` or `true` to enable.
- `use_syslog` - Log to syslog as well. - `console` Do not write log messages to log files, instead print them in the console. Set to `1` or `true` to enable. Default is
- `syslog_level` - Logging level for logging to syslog. `1` if Clickhouse does not run in daemon mode, `0` otherwise.
- `stream_compress` Compress `log` and `errorlog` with `lz4` stream compression. To enable, set to `1` or `true`. - `console_log_level` Log level for console output. Defaults to `level`.
- `formatting` Specify log format to be printed in console log (currently only `json` supported). - `formatting` Log format for console output. Currently, only `json` is supported).
- `use_syslog` - Also forward log output to syslog.
- `syslog_level` - Log level for logging to syslog.
Both log and error log file names (only file names, not directories) support date and time format specifiers. **Log format specifiers**
**Format specifiers** File names in `log` and `errorLog` paths support below format specifiers for the resulting file name (the directory part does not support them).
Using the following format specifiers, you can define a pattern for the resulting file name. “Example” column shows possible results for `2023-07-06 18:32:07`.
Column “Example” shows the output at `2023-07-06 18:32:07`.
| Specifier | Description | Example | | Specifier | Description | Example |
|-------------|---------------------------------------------------------------------------------------------------------------------|--------------------------| |-------------|---------------------------------------------------------------------------------------------------------------------|--------------------------|
@ -1537,18 +1540,37 @@ Using the following format specifiers, you can define a pattern for the resultin
</logger> </logger>
``` ```
Writing to the console can be configured. Config example: To print log messages only in the console:
``` xml ``` xml
<logger> <logger>
<level>information</level> <level>information</level>
<console>1</console> <console>true</console>
</logger>
```
**Per-level Overrides**
The log level of individual log names can be overridden. For example, to mute all messages of loggers "Backup" and "RBAC".
```xml
<logger>
<levels>
<logger>
<name>Backup</name>
<level>none</level>
</logger>
<logger>
<name>RBAC</name>
<level>none</level>
</logger>
</levels>
</logger> </logger>
``` ```
### syslog ### syslog
Writing to the syslog is also supported. Config example: To write log messages additionally to syslog:
``` xml ``` xml
<logger> <logger>
@ -1562,14 +1584,12 @@ Writing to the syslog is also supported. Config example:
</logger> </logger>
``` ```
Keys for syslog: Keys for `<syslog>`:
- use_syslog — Required setting if you want to write to the syslog. - `address` — The address of syslog in format `host\[:port\]`. If omitted, the local daemon is used.
- address — The host\[:port\] of syslogd. If omitted, the local daemon is used. - `hostname` — The name of the host from which logs are send. Optional.
- hostname — Optional. The name of the host that logs are sent from. - `facility` — The syslog [facility keyword](https://en.wikipedia.org/wiki/Syslog#Facility). Must be specified uppercase with a “LOG_” prefix, e.g. `LOG_USER`, `LOG_DAEMON`, `LOG_LOCAL3`, etc. Default value: `LOG_USER` if `address` is specified, `LOG_DAEMON` otherwise.
- facility — [The syslog facility keyword](https://en.wikipedia.org/wiki/Syslog#Facility) in uppercase letters with the “LOG_” prefix: (`LOG_USER`, `LOG_DAEMON`, `LOG_LOCAL3`, and so on). - `format` Log message format. Possible values: `bsd` and `syslog.`
Default value: `LOG_USER` if `address` is specified, `LOG_DAEMON` otherwise.
- format Message format. Possible values: `bsd` and `syslog.`
### Log formats ### Log formats
@ -1588,6 +1608,7 @@ You can specify the log format that will be outputted in the console log. Curren
"source_line": "192" "source_line": "192"
} }
``` ```
To enable JSON logging support, use the following snippet: To enable JSON logging support, use the following snippet:
```xml ```xml