-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Converts logging README format to be compatible with new docs system #91958
Changes from all commits
1a78b7b
25af5ed
b66d739
5fedcd4
bf6fdb4
4e3ea2b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
--- | ||
id: kibCoreLogging | ||
slug: /kibana-dev-docs/services/logging | ||
title: Logging system | ||
image: https://source.unsplash.com/400x175/?Logging | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume the unsplash images are just a placeholder thing? I noticed these in a few other docs from the new system but don't see those images surfaced anywhere. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They're a placeholder and are optional at this point. I added it simply to follow what I also saw was being done in other docs. |
||
summary: Core logging contains the system and service for Kibana logs. | ||
date: 2020-12-02 | ||
tags: ['kibana','dev', 'contributor', 'api docs'] | ||
--- | ||
|
||
# Logging | ||
- [Loggers, Appenders and Layouts](#loggers-appenders-and-layouts) | ||
- [Logger hierarchy](#logger-hierarchy) | ||
|
@@ -16,7 +26,7 @@ | |
- [Log record format changes](#log-record-format-changes) | ||
|
||
The way logging works in Kibana is inspired by `log4j 2` logging framework used by [Elasticsearch](https://www.elastic.co/guide/en/elasticsearch/reference/current/settings.html#logging). | ||
The main idea is to have consistent logging behaviour (configuration, log format etc.) across the entire Elastic Stack | ||
The main idea is to have consistent logging behaviour (configuration, log format etc.) across the entire Elastic Stack | ||
where possible. | ||
|
||
## Loggers, Appenders and Layouts | ||
|
@@ -34,25 +44,28 @@ __Layouts__ define how log messages are formatted and what type of information t | |
|
||
## Logger hierarchy | ||
|
||
Every logger has its unique context name that follows hierarchical naming rule. The logger is considered to be an | ||
Every logger has its unique context name that follows hierarchical naming rule. The logger is considered to be an | ||
ancestor of another logger if its name followed by a `.` is a prefix of the descendant logger name. For example logger | ||
with `a.b` context name is an ancestor of logger with `a.b.c` context name. All top-level loggers are descendants of special | ||
logger with `root` context name that resides at the top of the logger hierarchy. This logger always exists and | ||
logger with `root` context name that resides at the top of the logger hierarchy. This logger always exists and | ||
fully configured. | ||
|
||
Developer can configure _log level_ and _appenders_ that should be used within particular context name. If logger configuration | ||
specifies only _log level_ then _appenders_ configuration will be inherited from the ancestor logger. | ||
specifies only _log level_ then _appenders_ configuration will be inherited from the ancestor logger. | ||
|
||
__Note:__ in the current implementation log messages are only forwarded to appenders configured for a particular logger | ||
__Note:__ | ||
In the current implementation log messages are only forwarded to appenders configured for a particular logger | ||
context name or to appenders of the closest ancestor if current logger doesn't have any appenders configured. That means that | ||
we __don't support__ so called _appender additivity_ when log messages are forwarded to _every_ distinct appender within | ||
ancestor chain including `root`. | ||
|
||
## Log level | ||
|
||
Currently we support the following log levels: _all_, _fatal_, _error_, _warn_, _info_, _debug_, _trace_, _off_. | ||
|
||
Levels are ordered, so _all_ > _fatal_ > _error_ > _warn_ > _info_ > _debug_ > _trace_ > _off_. | ||
A log record is being logged by the logger if its level is higher than or equal to the level of its logger. Otherwise, | ||
|
||
A log record is being logged by the logger if its level is higher than or equal to the level of its logger. Otherwise, | ||
the log record is ignored. | ||
|
||
The _all_ and _off_ levels can be used only in configuration and are just handy shortcuts that allow developer to log every | ||
|
@@ -61,15 +74,15 @@ log record or disable logging entirely for the specific context name. | |
## Layouts | ||
|
||
Every appender should know exactly how to format log messages before they are written to the console or file on the disk. | ||
This behaviour is controlled by the layouts and configured through `appender.layout` configuration property for every | ||
This behaviour is controlled by the layouts and configured through `appender.layout` configuration property for every | ||
custom appender (see examples in [Configuration](#configuration)). Currently we don't define any default layout for the | ||
custom appenders, so one should always make the choice explicitly. | ||
|
||
There are two types of layout supported at the moment: `pattern` and `json`. | ||
There are two types of layout supported at the moment: `pattern` and `json`. | ||
|
||
### Pattern layout | ||
With `pattern` layout it's possible to define a string pattern with special placeholders `%conversion_pattern` (see the table below) that | ||
will be replaced with data from the actual log message. By default the following pattern is used: | ||
will be replaced with data from the actual log message. By default the following pattern is used: | ||
`[%date][%level][%logger]%meta %message`. Also `highlight` option can be enabled for `pattern` layout so that | ||
some parts of the log message are highlighted with different colors that may be quite handy if log messages are forwarded | ||
to the terminal with color support. | ||
|
@@ -111,7 +124,7 @@ Example of `%meta` output: | |
|
||
##### date | ||
Outputs the date of the logging event. The date conversion specifier may be followed by a set of braces containing a name of predefined date format and canonical timezone name. | ||
Timezone name is expected to be one from [TZ database name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). | ||
Timezone name is expected to be one from [TZ database name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). | ||
Timezone defaults to the host timezone when not explicitly specified. | ||
Example of `%date` output: | ||
|
||
|
@@ -130,7 +143,7 @@ Example of `%date` output: | |
Outputs the process ID. | ||
|
||
### JSON layout | ||
With `json` layout log messages will be formatted as JSON strings that include timestamp, log level, context name, message | ||
With `json` layout log messages will be formatted as JSON strings that include timestamp, log level, context name, message | ||
text and any other metadata that may be associated with the log message itself. | ||
|
||
## Appenders | ||
|
@@ -160,7 +173,7 @@ logging: | |
type: size-limit | ||
size: 50mb | ||
strategy: | ||
//... | ||
//... | ||
layout: | ||
type: pattern | ||
``` | ||
|
@@ -188,7 +201,7 @@ logging: | |
interval: 10s | ||
modulate: true | ||
strategy: | ||
//... | ||
//... | ||
layout: | ||
type: pattern | ||
``` | ||
|
@@ -202,10 +215,10 @@ How often a rollover should occur. | |
The default value is `24h` | ||
|
||
- `modulate` | ||
|
||
Whether the interval should be adjusted to cause the next rollover to occur on the interval boundary. | ||
For example, when true, if the interval is `4h` and the current hour is 3 am then the first rollover will occur at 4 am | ||
|
||
For example, when true, if the interval is `4h` and the current hour is 3 am then the first rollover will occur at 4 am | ||
and then next ones will occur at 8 am, noon, 4pm, etc. | ||
|
||
The default value is `true`. | ||
|
@@ -332,8 +345,8 @@ Here is what we get with the config above: | |
| metrics.ops | console | debug | | ||
|
||
|
||
The `root` logger has a dedicated configuration node since this context name is special and should always exist. By | ||
default `root` is configured with `info` level and `default` appender that is also always available. This is the | ||
The `root` logger has a dedicated configuration node since this context name is special and should always exist. By | ||
default `root` is configured with `info` level and `default` appender that is also always available. This is the | ||
configuration that all custom loggers will use unless they're re-configured explicitly. | ||
|
||
For example to see _all_ log messages that fall back on the `root` logger configuration, just add one line to the configuration: | ||
|
@@ -392,8 +405,8 @@ The message contains some high-level information, and the corresponding log meta | |
|
||
## Usage | ||
|
||
Usage is very straightforward, one should just get a logger for a specific context name and use it to log messages with | ||
different log level. | ||
Usage is very straightforward, one should just get a logger for a specific context name and use it to log messages with | ||
different log level. | ||
|
||
```typescript | ||
const logger = kibana.logger.get('server'); | ||
|
@@ -436,7 +449,7 @@ All log messages handled by `root` context are forwarded to the legacy logging s | |
root appenders, make sure that it contains `default` appender to provide backward compatibility. | ||
**Note**: If you define an appender for a context name, the log messages aren't handled by the | ||
`root` context anymore and not forwarded to the legacy logging service. | ||
|
||
#### logging.dest | ||
By default logs in *stdout*. With new Kibana logging you can use pre-existing `console` appender or | ||
define a custom one. | ||
|
@@ -446,7 +459,7 @@ logging: | |
- name: plugins.myPlugin | ||
appenders: [console] | ||
``` | ||
Logs in a *file* if given file path. You should define a custom appender with `type: file` | ||
Logs in a *file* if given file path. You should define a custom appender with `type: file` | ||
```yaml | ||
|
||
logging: | ||
|
@@ -459,13 +472,13 @@ logging: | |
loggers: | ||
- name: plugins.myPlugin | ||
appenders: [file] | ||
``` | ||
``` | ||
#### logging.json | ||
Defines the format of log output. Logs in JSON if `true`. With new logging config you can adjust | ||
the output format with [layouts](#layouts). | ||
|
||
#### logging.quiet | ||
Suppresses all logging output other than error messages. With new logging, config can be achieved | ||
Suppresses all logging output other than error messages. With new logging, config can be achieved | ||
with adjusting minimum required [logging level](#log-level). | ||
```yaml | ||
loggers: | ||
|
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.
AFAIK, this doc is only used in the new Docs system, so linking to the
kibCoreLogging
section should be ok but please correct me if I'm wrong.The other changes are all white-space changes for some reason.