-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add documentation for the log configuration #45940
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
docs/pages/admin-guides/management/diagnostics/logging.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
--- | ||
title: Logger Configuration | ||
description: Explains how to configure the logger on a Teleport instance. | ||
--- | ||
|
||
In the configuration file of a Teleport instance, you can configure the logger's behavior by defining the output | ||
destination, severity level, and output format. | ||
|
||
```yaml | ||
teleport: | ||
log: | ||
output: stderr | ||
severity: INFO | ||
format: | ||
output: text | ||
extra_fields: [caller, level] | ||
``` | ||
|
||
If the output parameter is not defined or set as empty, `stderr` (aliases `err` or `2`) is used by default. | ||
Other available options for defining the output include `stdout` (aliases `out` or `1`), `syslog` for writing | ||
to the syslog file, or a filepath for direct writing to a log file destination. | ||
|
||
Severity has several levels, which are sorted by decreasing priority: | ||
- `err`, `error` - used for errors that require action from the user. | ||
- `warn`, `warning` - non-critical entries that deserve attention. | ||
- `info` or empty value - general operational entries about what's going on inside the application. | ||
- `debug` - usually only enabled when debugging, verbose logging. | ||
- `trace` - designates more detailed information about actions and events. | ||
|
||
When we choose `info` severity level, `warning` and `error` are also applied by priority rule. | ||
|
||
The default format for log output is `text`. Another available format is `json`, which may simplify log | ||
parsing for systems like Logstash, Loki, or other log aggregators. | ||
|
||
Format `extra_fields` defines additional fields which must be added to the log output: | ||
- `level` is the log field that stores the verbosity. | ||
- `component` is the log field that stores the calling component. | ||
- `caller` is the log field that stores the calling file and line number. | ||
- `timestamp` is the field that stores the timestamp the log was emitted. | ||
|
||
On systemd-based distributions you can watch the log output by running the following command: | ||
|
||
```code | ||
$ teleport install systemd -o /etc/systemd/system/teleport.service | ||
$ systemctl enable teleport | ||
$ journalctl -fu teleport | ||
``` | ||
|
||
## Log rotation support | ||
|
||
To store logs as a file, the filepath should be set in the `log.output` configuration. | ||
|
||
```yaml | ||
teleport: | ||
log: | ||
output: /var/lib/teleport/log/output.log | ||
``` | ||
|
||
When Teleport opens or creates a new log file, a filesystem watcher is launched in the background to monitor the file modifications. | ||
If the log file is renamed, moved, or deleted, Teleport automatically creates a new one. | ||
This is useful for implementing log rotation without needing to restart or interrupt the main service. | ||
|
||
Using `logrotate` as an example, you may define the following config `/etc/logrotate.d/teleport.conf` | ||
to rotate Teleport log file weekly: | ||
|
||
``` | ||
/var/lib/teleport/log/output.log { | ||
weekly | ||
compress | ||
notifempty | ||
} | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we ever use "trace" level in our code? I don't think we do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we use, but very limited #45940 (comment), so might be better to remove?