From aac1dc3e1dfc34dbc21cf75833f5a5e308225d8a Mon Sep 17 00:00:00 2001 From: Christiane Heiligers Date: Mon, 8 Mar 2021 15:33:07 -0700 Subject: [PATCH 01/16] Deprecates legacy logging dest, json, verbosity and rotate configurations --- docs/migration/migrate_8_0.asciidoc | 125 ++++++++++++++++++ .../deprecation/core_deprecations.test.ts | 80 ++++++++++- .../config/deprecation/core_deprecations.ts | 75 ++++++++++- 3 files changed, 271 insertions(+), 9 deletions(-) diff --git a/docs/migration/migrate_8_0.asciidoc b/docs/migration/migrate_8_0.asciidoc index 5452621440ed8..73cc167ddf907 100644 --- a/docs/migration/migrate_8_0.asciidoc +++ b/docs/migration/migrate_8_0.asciidoc @@ -80,6 +80,131 @@ logging: ------------------- See https://github.com/elastic/kibana/pull/87939 for more details. +[float] +==== Logging destination is specified by the appender +*Details:* Previously log destination would be `stdout` and could be changed to `file` using `logging.dest`. + +*Impact:* To restore the previous behavior, in kibana.yml use the `console` appender to send logs to `stdout`. +[source,yaml] +------------------- +logging: + loggers: + - name: plugins.myPlugin + appenders: [console] +------------------- + +To send logs to `file` with a given file path, you should define a custom appender with `type:file`: +[source,yaml] +------------------- +logging: + appenders: + file: + type: file + fileName: /var/log/kibana.log + layout: + type: pattern + loggers: + - name: plugins.myPlugin + appenders: [file] +------------------- + +[float] +==== Specify log event output with root +*Details:* Previously logging output would be specified by `logging.silent` (none), 'logging.quiet' (error messages only) and `logging.verbose` (all). + +*Impact:* To restore the previous behavior, in kibana.yml specify `logging.root.level` as one of `off`, `error`, `all`: +[source,yaml] +------------------- +# suppress all logs +logging: + root: + appenders: [default] + level: off +------------------- + +[source,yaml] +------------------- +# only log error messages +logging: + root: + appenders: [default] + level: error +------------------- + +[source,yaml] +------------------- +# log all events +logging: + root: + appenders: [default] + level: all +------------------- + +[float] +==== Suppress all log output with root +*Details:* Previously all logging output would be suppressed if `logging.silent` was true. + +*Impact:* To restore the previous behavior, in kibana.yml turn `logging.root.level` to 'off'. +[source,yaml] +------------------- +logging: + root: + appenders: [default] + level: off +------------------- + +[float] +==== Suppress log output with root +*Details:* Previously all logging output other than error messages would be suppressed if `logging.quiet` was true. + +*Impact:* To restore the previous behavior, in kibana.yml turn `logging.root.level` to 'error'. +[source,yaml] +------------------- +logging: + root: + appenders: [default] + level: error +------------------- + +[float] +==== Log all output with root +*Details:* Previously all events would be logged if `logging.verbose` was true. + +*Impact:* To restore the previous behavior, in kibana.yml turn `logging.root.level` to 'all'. +[source,yaml] +------------------- +logging: + root: + appenders: [default] + level: all +------------------- + +[float] +==== Declare log message format for each custom appender +*Details:* Previously all events would be logged in `json` format when `logging.json` was true. + +*Impact:* To restore the previous behavior, in kibana.yml configure the logging format for each custom appender with the `appender.layout` property. There is no default for custom appenders and each one must be configured expilictly. + +[source,yaml] +------------------- +logging: + appenders: + custom_console: + type: console + layout: + type: pattern + appenders: + custom_json: + type: console + layout: + type: json + loggers: + - name: plugins.myPlugin + appenders: [custom_console] + - name: plugins.myOtherPlugin + appenders: [custom_json] +------------------- + [float] ==== `xpack.security.authProviders` is no longer valid *Details:* The deprecated `xpack.security.authProviders` setting in the `kibana.yml` file has been removed. diff --git a/src/core/server/config/deprecation/core_deprecations.test.ts b/src/core/server/config/deprecation/core_deprecations.test.ts index 4d7dafd2162c2..6e820efa8fc12 100644 --- a/src/core/server/config/deprecation/core_deprecations.test.ts +++ b/src/core/server/config/deprecation/core_deprecations.test.ts @@ -244,7 +244,7 @@ describe('core deprecations', () => { }); expect(messages).toMatchInlineSnapshot(` Array [ - "\\"logging.events.ops\\" has been deprecated and will be removed in 8.0. To access ops data moving forward, please enable debug logs for the \\"metrics.ops\\" context in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.md", + "\\"logging.events.ops\\" has been deprecated and will be removed in 8.0. To access ops data moving forward, please enable debug logs for the \\"metrics.ops\\" context in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx", ] `); }); @@ -264,7 +264,7 @@ describe('core deprecations', () => { }); expect(messages).toMatchInlineSnapshot(` Array [ - "\\"logging.events.request\\" and \\"logging.events.response\\" have been deprecated and will be removed in 8.0. To access request and/or response data moving forward, please enable debug logs for the \\"http.server.response\\" context in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.md", + "\\"logging.events.request\\" and \\"logging.events.response\\" have been deprecated and will be removed in 8.0. To access request and/or response data moving forward, please enable debug logs for the \\"http.server.response\\" context in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx", ] `); }); @@ -275,7 +275,7 @@ describe('core deprecations', () => { }); expect(messages).toMatchInlineSnapshot(` Array [ - "\\"logging.events.request\\" and \\"logging.events.response\\" have been deprecated and will be removed in 8.0. To access request and/or response data moving forward, please enable debug logs for the \\"http.server.response\\" context in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.md", + "\\"logging.events.request\\" and \\"logging.events.response\\" have been deprecated and will be removed in 8.0. To access request and/or response data moving forward, please enable debug logs for the \\"http.server.response\\" context in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx", ] `); }); @@ -286,7 +286,7 @@ describe('core deprecations', () => { }); expect(messages).toMatchInlineSnapshot(` Array [ - "\\"logging.events.request\\" and \\"logging.events.response\\" have been deprecated and will be removed in 8.0. To access request and/or response data moving forward, please enable debug logs for the \\"http.server.response\\" context in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.md", + "\\"logging.events.request\\" and \\"logging.events.response\\" have been deprecated and will be removed in 8.0. To access request and/or response data moving forward, please enable debug logs for the \\"http.server.response\\" context in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx", ] `); }); @@ -306,7 +306,7 @@ describe('core deprecations', () => { }); expect(messages).toMatchInlineSnapshot(` Array [ - "\\"logging.timezone\\" has been deprecated and will be removed in 8.0. To set the timezone moving forward, please add a timezone date modifier to the log pattern in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.md", + "\\"logging.timezone\\" has been deprecated and will be removed in 8.0. To set the timezone moving forward, please add a timezone date modifier to the log pattern in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx", ] `); }); @@ -318,4 +318,74 @@ describe('core deprecations', () => { expect(messages).toEqual([]); }); }); + + describe('logging.dest', () => { + it('warns when dest is used', () => { + const { messages } = applyCoreDeprecations({ + logging: { dest: 'stdout' }, + }); + expect(messages).toMatchInlineSnapshot(` + Array [ + "\\"logging.dest\\" has been deprecated and will be removed in 8.0. To set the destination moving forward, you can use the \\"console\\" appender in your logging configuration or define a custom one. For more details, see https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", + ] + `); + }); + it.todo('does not warn when ...'); + }); + + describe('logging.quiet', () => { + it('warns when quiet is used', () => { + const { messages } = applyCoreDeprecations({ + logging: { quiet: true }, + }); + expect(messages).toMatchInlineSnapshot(` + Array [ + "\\"logging.quiet\\" has been deprecated and will be removed in 8.0. To suppress logging output other than error messages moving forward, you can use \\"logging.root.level: error\\" in your logging configuration. For more details, see https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", + ] + `); + }); + it.todo('does not warn when .....'); + }); + + describe('logging.silent', () => { + it('warns when silent is used', () => { + const { messages } = applyCoreDeprecations({ + logging: { silent: true }, + }); + expect(messages).toMatchInlineSnapshot(` + Array [ + "\\"logging.silent\\" has been deprecated and will be removed in 8.0. To suppress all logging output moving forward, you can use \\"logging.root.level: off\\" in your logging configuration. For more details, see https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", + ] + `); + }); + it.todo('does not warn when .....'); + }); + + describe('logging.verbose', () => { + it('warns when verbose is used', () => { + const { messages } = applyCoreDeprecations({ + logging: { verbose: true }, + }); + expect(messages).toMatchInlineSnapshot(` + Array [ + "\\"logging.verbose\\" has been deprecated and will be removed in 8.0. To log all events moving forward, you can use \\"logging.root.level: all\\" in your logging configuration. For more details, see https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", + ] + `); + }); + it.todo('does not warn when .....'); + }); + + describe('logging.json', () => { + it('warns when json is used', () => { + const { messages } = applyCoreDeprecations({ + logging: { json: true }, + }); + expect(messages).toMatchInlineSnapshot(` + Array [ + "\\"logging.json\\" has been deprecated and will be removed in 8.0. To specify log message format moving forward, you must configure the \\"appender.layout\\" property for every custom appender in your logging configuration. There is currently no default layout for custom appenders and each one must be declared explicitly. For more details, see https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", + ] + `); + }); + it.todo('does not warn when .....'); + }); }); diff --git a/src/core/server/config/deprecation/core_deprecations.ts b/src/core/server/config/deprecation/core_deprecations.ts index fbdbaeb14fd59..1ae8de31cb3d2 100644 --- a/src/core/server/config/deprecation/core_deprecations.ts +++ b/src/core/server/config/deprecation/core_deprecations.ts @@ -102,14 +102,14 @@ const mapManifestServiceUrlDeprecation: ConfigDeprecation = (settings, fromPath, } return settings; }; - +// TODO: convert all links to the logging README to doc_links once we have formal docs for KP logging const opsLoggingEventDeprecation: ConfigDeprecation = (settings, fromPath, log) => { if (has(settings, 'logging.events.ops')) { log( '"logging.events.ops" has been deprecated and will be removed ' + 'in 8.0. To access ops data moving forward, please enable debug logs for the ' + '"metrics.ops" context in your logging configuration. For more details, see ' + - 'https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.md' + 'https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx' ); } return settings; @@ -121,7 +121,7 @@ const requestLoggingEventDeprecation: ConfigDeprecation = (settings, fromPath, l '"logging.events.request" and "logging.events.response" have been deprecated and will be removed ' + 'in 8.0. To access request and/or response data moving forward, please enable debug logs for the ' + '"http.server.response" context in your logging configuration. For more details, see ' + - 'https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.md' + 'https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx' ); } return settings; @@ -133,11 +133,73 @@ const timezoneLoggingDeprecation: ConfigDeprecation = (settings, fromPath, log) '"logging.timezone" has been deprecated and will be removed ' + 'in 8.0. To set the timezone moving forward, please add a timezone date modifier to the log pattern ' + 'in your logging configuration. For more details, see ' + - 'https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.md' + 'https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx' + ); + } + return settings; +}; +// logging.dest +const destLoggingDeprecation: ConfigDeprecation = (settings, fromPath, log) => { + if (has(settings, 'logging.dest')) { + log( + '"logging.dest" has been deprecated and will be removed ' + + 'in 8.0. To set the destination moving forward, you can use the "console" appender ' + + 'in your logging configuration or define a custom one. For more details, see ' + + 'https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.' + ); + } + return settings; +}; +// logging.quiet -> logging.root.level: error +const quietLoggingDeprecation: ConfigDeprecation = (settings, fromPath, log) => { + if (has(settings, 'logging.quiet')) { + log( + '"logging.quiet" has been deprecated and will be removed ' + + 'in 8.0. To suppress logging output other than error messages moving forward, ' + + 'you can use "logging.root.level: error" in your logging configuration. For more details, see ' + + 'https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.' + ); + } + return settings; +}; +// logging.silent -> logging.root.level: off +const silentLoggingDeprecation: ConfigDeprecation = (settings, fromPath, log) => { + if (has(settings, 'logging.silent')) { + log( + '"logging.silent" has been deprecated and will be removed ' + + 'in 8.0. To suppress all logging output moving forward, ' + + 'you can use "logging.root.level: off" in your logging configuration. For more details, see ' + + 'https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.' + ); + } + return settings; +}; +// logging.verbose -> logging.root.level: all +const verboseLoggingDeprecation: ConfigDeprecation = (settings, fromPath, log) => { + if (has(settings, 'logging.verbose')) { + log( + '"logging.verbose" has been deprecated and will be removed ' + + 'in 8.0. To log all events moving forward, ' + + 'you can use "logging.root.level: all" in your logging configuration. For more details, see ' + + 'https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.' + ); + } + return settings; +}; + +// logging.json -> adjust output format with [layouts](https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx#layouts) +const jsonLoggingDeprecation: ConfigDeprecation = (settings, fromPath, log) => { + if (has(settings, 'logging.json')) { + log( + '"logging.json" has been deprecated and will be removed ' + + 'in 8.0. To specify log message format moving forward, ' + + 'you must configure the "appender.layout" property for every custom appender in your logging configuration. There is currently no default layout for custom appenders and each one must be declared explicitly. For more details, see ' + + 'https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.' ); } return settings; }; +// logging.rotate -> export const coreDeprecationProvider: ConfigDeprecationProvider = ({ rename, unusedFromRoot }) => [ unusedFromRoot('savedObjects.indexCheckTimeout'), @@ -176,4 +238,9 @@ export const coreDeprecationProvider: ConfigDeprecationProvider = ({ rename, unu opsLoggingEventDeprecation, requestLoggingEventDeprecation, timezoneLoggingDeprecation, + destLoggingDeprecation, + quietLoggingDeprecation, + silentLoggingDeprecation, + verboseLoggingDeprecation, + jsonLoggingDeprecation, ]; From 58df9924adf9c6597c16c72efd68b2ecaabcf668 Mon Sep 17 00:00:00 2001 From: Christiane Heiligers Date: Tue, 9 Mar 2021 11:39:24 -0700 Subject: [PATCH 02/16] Adds logging rotate options to README --- .../deprecation/core_deprecations.test.ts | 77 +++++++++++++++---- .../config/deprecation/core_deprecations.ts | 69 ++++++++--------- src/core/server/logging/README.mdx | 21 ++++- 3 files changed, 112 insertions(+), 55 deletions(-) diff --git a/src/core/server/config/deprecation/core_deprecations.test.ts b/src/core/server/config/deprecation/core_deprecations.test.ts index 6e820efa8fc12..3f4b5cadba556 100644 --- a/src/core/server/config/deprecation/core_deprecations.test.ts +++ b/src/core/server/config/deprecation/core_deprecations.test.ts @@ -330,49 +330,49 @@ describe('core deprecations', () => { ] `); }); - it.todo('does not warn when ...'); + it('warns when dest path is given', () => { + const { messages } = applyCoreDeprecations({ + logging: { dest: '/log-log.txt' }, + }); + expect(messages).toMatchInlineSnapshot(` + Array [ + "\\"logging.dest\\" has been deprecated and will be removed in 8.0. To set the destination moving forward, you can use the \\"console\\" appender in your logging configuration or define a custom one. For more details, see https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", + ] + `); + }); }); - describe('logging.quiet', () => { + describe('logging.quiet, logging.silent and logging.verbose', () => { it('warns when quiet is used', () => { const { messages } = applyCoreDeprecations({ logging: { quiet: true }, }); expect(messages).toMatchInlineSnapshot(` Array [ - "\\"logging.quiet\\" has been deprecated and will be removed in 8.0. To suppress logging output other than error messages moving forward, you can use \\"logging.root.level: error\\" in your logging configuration. For more details, see https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", + "\\"logging.quiet\\", \\"logging.silent\\" and \\"logging.verbose\\" have been deprecated and will be removed in 8.0. Moving forward, you can use \\"logging.root.level\\" in your logging configuration. Levels \\"error\\", \\"off\\" and \\"all\\" are equivalent to \\"quiet\\", \\"silent\\" and \\"verbose\\". For more details, see https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", ] `); }); - it.todo('does not warn when .....'); - }); - - describe('logging.silent', () => { it('warns when silent is used', () => { const { messages } = applyCoreDeprecations({ logging: { silent: true }, }); expect(messages).toMatchInlineSnapshot(` Array [ - "\\"logging.silent\\" has been deprecated and will be removed in 8.0. To suppress all logging output moving forward, you can use \\"logging.root.level: off\\" in your logging configuration. For more details, see https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", + "\\"logging.quiet\\", \\"logging.silent\\" and \\"logging.verbose\\" have been deprecated and will be removed in 8.0. Moving forward, you can use \\"logging.root.level\\" in your logging configuration. Levels \\"error\\", \\"off\\" and \\"all\\" are equivalent to \\"quiet\\", \\"silent\\" and \\"verbose\\". For more details, see https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", ] `); }); - it.todo('does not warn when .....'); - }); - - describe('logging.verbose', () => { it('warns when verbose is used', () => { const { messages } = applyCoreDeprecations({ logging: { verbose: true }, }); expect(messages).toMatchInlineSnapshot(` Array [ - "\\"logging.verbose\\" has been deprecated and will be removed in 8.0. To log all events moving forward, you can use \\"logging.root.level: all\\" in your logging configuration. For more details, see https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", + "\\"logging.quiet\\", \\"logging.silent\\" and \\"logging.verbose\\" have been deprecated and will be removed in 8.0. Moving forward, you can use \\"logging.root.level\\" in your logging configuration. Levels \\"error\\", \\"off\\" and \\"all\\" are equivalent to \\"quiet\\", \\"silent\\" and \\"verbose\\". For more details, see https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", ] `); }); - it.todo('does not warn when .....'); }); describe('logging.json', () => { @@ -382,10 +382,55 @@ describe('core deprecations', () => { }); expect(messages).toMatchInlineSnapshot(` Array [ - "\\"logging.json\\" has been deprecated and will be removed in 8.0. To specify log message format moving forward, you must configure the \\"appender.layout\\" property for every custom appender in your logging configuration. There is currently no default layout for custom appenders and each one must be declared explicitly. For more details, see https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", + "\\"logging.json\\" has been deprecated and will be removed in 8.0. To specify log message format moving forward, you can configure the \\"appender.layout\\" property for every custom appender in your logging configuration. There is currently no default layout for custom appenders and each one must be declared explicitly. For more details, see https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", + ] + `); + }); + }); + + describe('logging.rotate.enabled, logging.rotate.usePolling, logging.rotate.pollingInterval, logging.rotate.everyBytes and logging.rotate.keepFiles', () => { + it('warns when logging.rotate configurations are used', () => { + const { messages } = applyCoreDeprecations({ + logging: { rotate: { enabled: true } }, + }); + expect(messages).toMatchInlineSnapshot(` + Array [ + "\\"logging.rotate\\" and sub-options have been deprecated and will be removed in 8.0. Moving forward, you can enabled log rotation using the \\"rolling-file\\" appender for a context in your logging confugration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx#rolling-file-appender", + ] + `); + }); + + it('warns when logging.rotate polling configurations are used', () => { + const { messages } = applyCoreDeprecations({ + logging: { rotate: { enabled: true, usePolling: true, pollingInterval: 5000 } }, + }); + expect(messages).toMatchInlineSnapshot(` + Array [ + "\\"logging.rotate\\" and sub-options have been deprecated and will be removed in 8.0. Moving forward, you can enabled log rotation using the \\"rolling-file\\" appender for a context in your logging confugration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx#rolling-file-appender", + ] + `); + }); + + it('warns when logging.rotate.everyBytes configurations are used', () => { + const { messages } = applyCoreDeprecations({ + logging: { rotate: { enabled: true, everyBytes: 1048576 } }, + }); + expect(messages).toMatchInlineSnapshot(` + Array [ + "\\"logging.rotate\\" and sub-options have been deprecated and will be removed in 8.0. Moving forward, you can enabled log rotation using the \\"rolling-file\\" appender for a context in your logging confugration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx#rolling-file-appender", + ] + `); + }); + + it('warns when logging.rotate.keepFiles is used', () => { + const { messages } = applyCoreDeprecations({ + logging: { rotate: { enabled: true, keepFiles: 1024 } }, + }); + expect(messages).toMatchInlineSnapshot(` + Array [ + "\\"logging.rotate\\" and sub-options have been deprecated and will be removed in 8.0. Moving forward, you can enabled log rotation using the \\"rolling-file\\" appender for a context in your logging confugration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx#rolling-file-appender", ] `); }); - it.todo('does not warn when .....'); }); }); diff --git a/src/core/server/config/deprecation/core_deprecations.ts b/src/core/server/config/deprecation/core_deprecations.ts index 1ae8de31cb3d2..5a841ba601671 100644 --- a/src/core/server/config/deprecation/core_deprecations.ts +++ b/src/core/server/config/deprecation/core_deprecations.ts @@ -102,7 +102,7 @@ const mapManifestServiceUrlDeprecation: ConfigDeprecation = (settings, fromPath, } return settings; }; -// TODO: convert all links to the logging README to doc_links once we have formal docs for KP logging + const opsLoggingEventDeprecation: ConfigDeprecation = (settings, fromPath, log) => { if (has(settings, 'logging.events.ops')) { log( @@ -138,7 +138,7 @@ const timezoneLoggingDeprecation: ConfigDeprecation = (settings, fromPath, log) } return settings; }; -// logging.dest + const destLoggingDeprecation: ConfigDeprecation = (settings, fromPath, log) => { if (has(settings, 'logging.dest')) { log( @@ -150,56 +150,52 @@ const destLoggingDeprecation: ConfigDeprecation = (settings, fromPath, log) => { } return settings; }; -// logging.quiet -> logging.root.level: error -const quietLoggingDeprecation: ConfigDeprecation = (settings, fromPath, log) => { - if (has(settings, 'logging.quiet')) { - log( - '"logging.quiet" has been deprecated and will be removed ' + - 'in 8.0. To suppress logging output other than error messages moving forward, ' + - 'you can use "logging.root.level: error" in your logging configuration. For more details, see ' + - 'https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.' - ); - } - return settings; -}; -// logging.silent -> logging.root.level: off -const silentLoggingDeprecation: ConfigDeprecation = (settings, fromPath, log) => { - if (has(settings, 'logging.silent')) { + +const quietSilentVerboseLoggingDeprecation: ConfigDeprecation = (settings, fromPath, log) => { + if ( + has(settings, 'logging.quiet') || + has(settings, 'logging.silent') || + has(settings, 'logging.verbose') + ) { log( - '"logging.silent" has been deprecated and will be removed ' + - 'in 8.0. To suppress all logging output moving forward, ' + - 'you can use "logging.root.level: off" in your logging configuration. For more details, see ' + + '"logging.quiet", "logging.silent" and "logging.verbose" have been deprecated and will be removed ' + + 'in 8.0. Moving forward, you can use "logging.root.level" in your logging configuration. ' + + 'Levels "error", "off" and "all" are equivalent to "quiet", "silent" and "verbose". For more details, see ' + 'https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.' ); } return settings; }; -// logging.verbose -> logging.root.level: all -const verboseLoggingDeprecation: ConfigDeprecation = (settings, fromPath, log) => { - if (has(settings, 'logging.verbose')) { + +const jsonLoggingDeprecation: ConfigDeprecation = (settings, fromPath, log) => { + if (has(settings, 'logging.json')) { log( - '"logging.verbose" has been deprecated and will be removed ' + - 'in 8.0. To log all events moving forward, ' + - 'you can use "logging.root.level: all" in your logging configuration. For more details, see ' + + '"logging.json" has been deprecated and will be removed ' + + 'in 8.0. To specify log message format moving forward, ' + + 'you can configure the "appender.layout" property for every custom appender in your logging configuration. There is currently no default layout for custom appenders and each one must be declared explicitly. For more details, see ' + 'https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.' ); } return settings; }; -// logging.json -> adjust output format with [layouts](https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx#layouts) -const jsonLoggingDeprecation: ConfigDeprecation = (settings, fromPath, log) => { - if (has(settings, 'logging.json')) { +const logRotateDeprecation: ConfigDeprecation = (settings, fromPath, log) => { + if ( + has(settings, 'logging.rotate.enabled') || + has(settings, 'logging.rotate.usePolling') || + has(settings, 'logging.rotate.pollingInterval') || + has(settings, 'logging.rotate.everyBytes') || + has(settings, 'logging.rotate.keepFiles') + ) { log( - '"logging.json" has been deprecated and will be removed ' + - 'in 8.0. To specify log message format moving forward, ' + - 'you must configure the "appender.layout" property for every custom appender in your logging configuration. There is currently no default layout for custom appenders and each one must be declared explicitly. For more details, see ' + - 'https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.' + '"logging.rotate" and sub-options have been deprecated and will be removed in 8.0. Moving forward, you can enabled ' + + 'log rotation using the "rolling-file" appender for a context in your logging confugration. ' + + 'For more details, see ' + + 'https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx#rolling-file-appender' ); } return settings; }; -// logging.rotate -> export const coreDeprecationProvider: ConfigDeprecationProvider = ({ rename, unusedFromRoot }) => [ unusedFromRoot('savedObjects.indexCheckTimeout'), @@ -239,8 +235,7 @@ export const coreDeprecationProvider: ConfigDeprecationProvider = ({ rename, unu requestLoggingEventDeprecation, timezoneLoggingDeprecation, destLoggingDeprecation, - quietLoggingDeprecation, - silentLoggingDeprecation, - verboseLoggingDeprecation, + quietSilentVerboseLoggingDeprecation, jsonLoggingDeprecation, + logRotateDeprecation, ]; diff --git a/src/core/server/logging/README.mdx b/src/core/server/logging/README.mdx index 63a7d8ecade6c..08e4ed34204c0 100644 --- a/src/core/server/logging/README.mdx +++ b/src/core/server/logging/README.mdx @@ -563,9 +563,9 @@ The log will be less verbose with `warn` level for the `server` context name: ### Logging config migration Compatibility with the legacy logging system is assured until the end of the `v7` version. -All log messages handled by `root` context are forwarded to the legacy logging service. If you re-write +All log messages handled by `root` context are forwarded to the legacy logging service using a `default` appender. If you re-write 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 +**Note**: If you define an appender for a context name, the log messages for that specific context aren't handled by the `root` context anymore and not forwarded to the legacy logging service. #### logging.dest @@ -659,6 +659,23 @@ and you can enable them by adjusting the minimum required [logging level](#log-l #### logging.filter TBD +#### logging.rotate +Specify the options for the logging rotate feature and only applicable when logs are written to file. +With the new logging config, the log rotation feature is provided by the `rolling-file` [appender](#rolling-file-appender). + +**`logging.rotate.enabled` and `logging.rotate.usePolling`** +Enables log rotation when `enabled` is set to `true`. The `usePolling` option is optional and can be used in systems where the watch api is not accurate. +With the new logging config log rotation is provided by the rolling file appender. Polling will apply by default when the `rolling-file` appender is configured. + +**`logging.rotate.pollingInterval`** +The number of milliseconds for the polling strategy in the case when `logging.rotate.usePolling` is enabled and defaults to 10000. +Possible range from 5000 to 3600000. With the new logging config an time interval can be configured with the +[TimeIntervalTriggeringPolicy](#timeintervaltriggeringpolicy) + +**`logging.rotate.everyBytes` and `logging.rotate.keepFiles`** +Maximum size of a log file and the number of most recent log files to keep on disk. With the new logging config the log size limit can be configured with the +[SizeLimitTriggeringPolicy](#sizelimitriggeringpolicy) and the number of files to keep with the `numeric` strategy `max` option. + ### Logging configuration via CLI | legacy logging | Kibana Platform logging| From 2fa7fe07ee61676382f7c9a03840817bb41f8826 Mon Sep 17 00:00:00 2001 From: Christiane Heiligers Date: Tue, 9 Mar 2021 17:08:08 -0700 Subject: [PATCH 03/16] Adds log rotation to migration guide docs --- docs/migration/migrate_8_0.asciidoc | 39 ++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/docs/migration/migrate_8_0.asciidoc b/docs/migration/migrate_8_0.asciidoc index 73cc167ddf907..55a9b522e0da1 100644 --- a/docs/migration/migrate_8_0.asciidoc +++ b/docs/migration/migrate_8_0.asciidoc @@ -84,7 +84,7 @@ See https://github.com/elastic/kibana/pull/87939 for more details. ==== Logging destination is specified by the appender *Details:* Previously log destination would be `stdout` and could be changed to `file` using `logging.dest`. -*Impact:* To restore the previous behavior, in kibana.yml use the `console` appender to send logs to `stdout`. +*Impact:* To restore the previous behavior, in `kibana.yml` use the `console` appender to send logs to `stdout`. [source,yaml] ------------------- logging: @@ -112,7 +112,7 @@ logging: ==== Specify log event output with root *Details:* Previously logging output would be specified by `logging.silent` (none), 'logging.quiet' (error messages only) and `logging.verbose` (all). -*Impact:* To restore the previous behavior, in kibana.yml specify `logging.root.level` as one of `off`, `error`, `all`: +*Impact:* To restore the previous behavior, in `kibana.yml` specify `logging.root.level` as one of `off`, `error`, `all`: [source,yaml] ------------------- # suppress all logs @@ -144,7 +144,7 @@ logging: ==== Suppress all log output with root *Details:* Previously all logging output would be suppressed if `logging.silent` was true. -*Impact:* To restore the previous behavior, in kibana.yml turn `logging.root.level` to 'off'. +*Impact:* To restore the previous behavior, in `kibana.yml` turn `logging.root.level` to 'off'. [source,yaml] ------------------- logging: @@ -157,7 +157,7 @@ logging: ==== Suppress log output with root *Details:* Previously all logging output other than error messages would be suppressed if `logging.quiet` was true. -*Impact:* To restore the previous behavior, in kibana.yml turn `logging.root.level` to 'error'. +*Impact:* To restore the previous behavior, in `kibana.yml` turn `logging.root.level` to 'error'. [source,yaml] ------------------- logging: @@ -170,7 +170,7 @@ logging: ==== Log all output with root *Details:* Previously all events would be logged if `logging.verbose` was true. -*Impact:* To restore the previous behavior, in kibana.yml turn `logging.root.level` to 'all'. +*Impact:* To restore the previous behavior, in `kibana.yml` turn `logging.root.level` to 'all'. [source,yaml] ------------------- logging: @@ -183,7 +183,7 @@ logging: ==== Declare log message format for each custom appender *Details:* Previously all events would be logged in `json` format when `logging.json` was true. -*Impact:* To restore the previous behavior, in kibana.yml configure the logging format for each custom appender with the `appender.layout` property. There is no default for custom appenders and each one must be configured expilictly. +*Impact:* To restore the previous behavior, in `kibana.yml` configure the logging format for each custom appender with the `appender.layout` property. There is no default for custom appenders and each one must be configured expilictly. [source,yaml] ------------------- @@ -205,6 +205,33 @@ logging: appenders: [custom_json] ------------------- +[float] +==== Configure log rotation with the rolling-file appender +*Details:* Previously log rotation would be enabled when `logging.rotate.enabled` was true. + +*Impact:* To restore the previous behavior, in `kibana.yml` use the `rolling-file` appender. + +[source,yaml] +------------------- +logging: + appenders: + rolling-file: + type: rolling-file + fileName: /var/logs/kibana.log + policy: + type: size-limit + size: 50mb + strategy: + type: numeric + pattern: '-%i' + max: 2 + layout: + type: pattern + loggers: + - name: plugins.myPlugin + appenders: [rolling-file] +------------------- + [float] ==== `xpack.security.authProviders` is no longer valid *Details:* The deprecated `xpack.security.authProviders` setting in the `kibana.yml` file has been removed. From 376e0474fda686239c546629e90e8e8dbb0f0514 Mon Sep 17 00:00:00 2001 From: Christiane Heiligers Date: Tue, 9 Mar 2021 17:56:17 -0700 Subject: [PATCH 04/16] Update config_deprecations jest integration tests --- .../config/integration_tests/config_deprecation.test.ts | 9 +++++++-- src/core/test_helpers/kbn_server.ts | 2 -- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/core/server/config/integration_tests/config_deprecation.test.ts b/src/core/server/config/integration_tests/config_deprecation.test.ts index 4cb0ec02d85f7..84f1025a48dd3 100644 --- a/src/core/server/config/integration_tests/config_deprecation.test.ts +++ b/src/core/server/config/integration_tests/config_deprecation.test.ts @@ -23,13 +23,17 @@ describe('configuration deprecations', () => { } }); - it('should not log deprecation warnings for default configuration', async () => { + it('should not log deprecation warnings for default configuration that is not one of `logging.verbose`, `logging.quiet` or `logging.silent`', async () => { root = kbnTestServer.createRoot(); await root.setup(); const logs = loggingSystemMock.collect(mockLoggingSystem); - expect(logs.warn.flat()).toMatchInlineSnapshot(`Array []`); + expect(logs.warn.flat()).toMatchInlineSnapshot(` + Array [ + "\\"logging.quiet\\", \\"logging.silent\\" and \\"logging.verbose\\" have been deprecated and will be removed in 8.0. Moving forward, you can use \\"logging.root.level\\" in your logging configuration. Levels \\"error\\", \\"off\\" and \\"all\\" are equivalent to \\"quiet\\", \\"silent\\" and \\"verbose\\". For more details, see https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", + ] + `); }); it('should log deprecation warnings for core deprecations', async () => { @@ -47,6 +51,7 @@ describe('configuration deprecations', () => { Array [ "optimize.lazy is deprecated and is no longer used", "optimize.lazyPort is deprecated and is no longer used", + "\\"logging.quiet\\", \\"logging.silent\\" and \\"logging.verbose\\" have been deprecated and will be removed in 8.0. Moving forward, you can use \\"logging.root.level\\" in your logging configuration. Levels \\"error\\", \\"off\\" and \\"all\\" are equivalent to \\"quiet\\", \\"silent\\" and \\"verbose\\". For more details, see https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", ] `); }); diff --git a/src/core/test_helpers/kbn_server.ts b/src/core/test_helpers/kbn_server.ts index 14f614643ac9f..b0c716c9fcb85 100644 --- a/src/core/test_helpers/kbn_server.ts +++ b/src/core/test_helpers/kbn_server.ts @@ -60,8 +60,6 @@ export function createRootWithSettings( configs: [], cliArgs: { dev: false, - quiet: false, - silent: false, watch: false, basePath: false, runExamples: false, From 08e9cba12943281ba313187cbcda1d97c4268d0f Mon Sep 17 00:00:00 2001 From: Christiane Heiligers Date: Tue, 9 Mar 2021 18:10:26 -0700 Subject: [PATCH 05/16] Adds cliArgs back --- src/core/test_helpers/kbn_server.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/test_helpers/kbn_server.ts b/src/core/test_helpers/kbn_server.ts index b0c716c9fcb85..14f614643ac9f 100644 --- a/src/core/test_helpers/kbn_server.ts +++ b/src/core/test_helpers/kbn_server.ts @@ -60,6 +60,8 @@ export function createRootWithSettings( configs: [], cliArgs: { dev: false, + quiet: false, + silent: false, watch: false, basePath: false, runExamples: false, From abae294f435e84d87b56f9e93b416fddef46c388 Mon Sep 17 00:00:00 2001 From: Christiane Heiligers Date: Fri, 12 Mar 2021 11:47:01 -0700 Subject: [PATCH 06/16] Fixes typos --- .../server/config/deprecation/core_deprecations.test.ts | 8 ++++---- src/core/server/config/deprecation/core_deprecations.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/server/config/deprecation/core_deprecations.test.ts b/src/core/server/config/deprecation/core_deprecations.test.ts index 3f4b5cadba556..0947b183c05e2 100644 --- a/src/core/server/config/deprecation/core_deprecations.test.ts +++ b/src/core/server/config/deprecation/core_deprecations.test.ts @@ -395,7 +395,7 @@ describe('core deprecations', () => { }); expect(messages).toMatchInlineSnapshot(` Array [ - "\\"logging.rotate\\" and sub-options have been deprecated and will be removed in 8.0. Moving forward, you can enabled log rotation using the \\"rolling-file\\" appender for a context in your logging confugration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx#rolling-file-appender", + "\\"logging.rotate\\" and sub-options have been deprecated and will be removed in 8.0. Moving forward, you can enabled log rotation using the \\"rolling-file\\" appender for a context in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx#rolling-file-appender", ] `); }); @@ -406,7 +406,7 @@ describe('core deprecations', () => { }); expect(messages).toMatchInlineSnapshot(` Array [ - "\\"logging.rotate\\" and sub-options have been deprecated and will be removed in 8.0. Moving forward, you can enabled log rotation using the \\"rolling-file\\" appender for a context in your logging confugration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx#rolling-file-appender", + "\\"logging.rotate\\" and sub-options have been deprecated and will be removed in 8.0. Moving forward, you can enabled log rotation using the \\"rolling-file\\" appender for a context in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx#rolling-file-appender", ] `); }); @@ -417,7 +417,7 @@ describe('core deprecations', () => { }); expect(messages).toMatchInlineSnapshot(` Array [ - "\\"logging.rotate\\" and sub-options have been deprecated and will be removed in 8.0. Moving forward, you can enabled log rotation using the \\"rolling-file\\" appender for a context in your logging confugration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx#rolling-file-appender", + "\\"logging.rotate\\" and sub-options have been deprecated and will be removed in 8.0. Moving forward, you can enabled log rotation using the \\"rolling-file\\" appender for a context in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx#rolling-file-appender", ] `); }); @@ -428,7 +428,7 @@ describe('core deprecations', () => { }); expect(messages).toMatchInlineSnapshot(` Array [ - "\\"logging.rotate\\" and sub-options have been deprecated and will be removed in 8.0. Moving forward, you can enabled log rotation using the \\"rolling-file\\" appender for a context in your logging confugration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx#rolling-file-appender", + "\\"logging.rotate\\" and sub-options have been deprecated and will be removed in 8.0. Moving forward, you can enabled log rotation using the \\"rolling-file\\" appender for a context in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx#rolling-file-appender", ] `); }); diff --git a/src/core/server/config/deprecation/core_deprecations.ts b/src/core/server/config/deprecation/core_deprecations.ts index 5a841ba601671..02a1ec87835f9 100644 --- a/src/core/server/config/deprecation/core_deprecations.ts +++ b/src/core/server/config/deprecation/core_deprecations.ts @@ -189,7 +189,7 @@ const logRotateDeprecation: ConfigDeprecation = (settings, fromPath, log) => { ) { log( '"logging.rotate" and sub-options have been deprecated and will be removed in 8.0. Moving forward, you can enabled ' + - 'log rotation using the "rolling-file" appender for a context in your logging confugration. ' + + 'log rotation using the "rolling-file" appender for a context in your logging configuration. ' + 'For more details, see ' + 'https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx#rolling-file-appender' ); From a389f4ec6f687bb651e0bb95aa962f5fe35b83f5 Mon Sep 17 00:00:00 2001 From: Christiane Heiligers Date: Fri, 12 Mar 2021 16:45:07 -0700 Subject: [PATCH 07/16] Retains support for cliArgs --verbose and --silent --- packages/kbn-config/src/env.ts | 5 ++- packages/kbn-legacy-logging/src/schema.ts | 19 +++++++--- src/cli/serve/serve.js | 27 +++++++++---- .../deprecation/core_deprecations.test.ts | 6 +-- .../config/deprecation/core_deprecations.ts | 38 +++++++++++++------ .../config_deprecation.test.ts | 4 +- src/core/test_helpers/kbn_server.ts | 2 +- 7 files changed, 69 insertions(+), 32 deletions(-) diff --git a/packages/kbn-config/src/env.ts b/packages/kbn-config/src/env.ts index 8526cfc7691ef..b6ff5e3b5aab2 100644 --- a/packages/kbn-config/src/env.ts +++ b/packages/kbn-config/src/env.ts @@ -22,8 +22,9 @@ export interface EnvOptions { export interface CliArgs { dev: boolean; envName?: string; - quiet: boolean; - silent: boolean; + /** @deprecated */ + quiet?: boolean; + silent?: boolean; watch: boolean; basePath: boolean; oss: boolean; diff --git a/packages/kbn-legacy-logging/src/schema.ts b/packages/kbn-legacy-logging/src/schema.ts index 2c5271157fb72..3233813bbd545 100644 --- a/packages/kbn-legacy-logging/src/schema.ts +++ b/packages/kbn-legacy-logging/src/schema.ts @@ -11,10 +11,15 @@ import Joi from 'joi'; const HANDLED_IN_KIBANA_PLATFORM = Joi.any().description( 'This key is handled in the new platform ONLY' ); - +/** + * @deprecated + * + * Legacy logging has been deprecated and will be removed in 8.0. + * Set up logging from the platform logging instead + */ export interface LegacyLoggingConfig { - silent: boolean; - quiet: boolean; + silent: boolean; // support for cli args + quiet?: boolean; // deprecated verbose: boolean; events: Record; dest: string; @@ -28,7 +33,7 @@ export interface LegacyLoggingConfig { pollingInterval: number; usePolling: boolean; pollingPolicyTestTimeout?: number; - }; + }; // all deprecated } export const legacyLoggingConfigSchema = Joi.object() @@ -38,27 +43,29 @@ export const legacyLoggingConfigSchema = Joi.object() root: HANDLED_IN_KIBANA_PLATFORM, silent: Joi.boolean().default(false), - + // deprecated quiet: Joi.boolean().when('silent', { is: true, then: Joi.boolean().default(true).valid(true), otherwise: Joi.boolean().default(false), }), - verbose: Joi.boolean().when('quiet', { is: true, then: Joi.valid(false).default(false), otherwise: Joi.boolean().default(false), }), events: Joi.any().default({}), + // deprecated dest: Joi.string().default('stdout'), filter: Joi.any().default({}), + // deprecated json: Joi.boolean().when('dest', { is: 'stdout', then: Joi.boolean().default(!process.stdout.isTTY), otherwise: Joi.boolean().default(true), }), timezone: Joi.string(), + // deprecated rotate: Joi.object() .keys({ enabled: Joi.boolean().default(false), diff --git a/src/cli/serve/serve.js b/src/cli/serve/serve.js index 891f2b0fff797..b0646b841b1f2 100644 --- a/src/cli/serve/serve.js +++ b/src/cli/serve/serve.js @@ -112,10 +112,19 @@ function applyConfigOverrides(rawConfig, opts, extraCliOptions) { if (opts.elasticsearch) set('elasticsearch.hosts', opts.elasticsearch.split(',')); if (opts.port) set('server.port', opts.port); if (opts.host) set('server.host', opts.host); - if (opts.quiet) set('logging.quiet', true); - if (opts.silent) set('logging.silent', true); - if (opts.verbose) set('logging.verbose', true); - if (opts.logFile) set('logging.dest', opts.logFile); + // if (opts.quiet) set('logging.quiet', true); // deprecated + + // retain support for cli flag `--silent` + if (opts.silent) { + // set('logging.level', 'off') && set('logging.root.level', 'off'); + set('logging.silent', true) && set('logging.root.level', 'off'); + } + // retain support for cli flag `--verbose` + if (opts.verbose) { + // set('logging.level', 'all') && set('logging.root.level', 'all'); + set('logging.verbose', true) && set('logging.root.level', 'all'); + } + // if (opts.logFile) set('logging.dest', opts.logFile); // deprecated set('plugins.scanDirs', _.compact([].concat(get('plugins.scanDirs'), opts.pluginDir))); set('plugins.paths', _.compact([].concat(get('plugins.paths'), opts.pluginPath))); @@ -140,11 +149,14 @@ export default function (program) { [getConfigPath()] ) .option('-p, --port ', 'The port to bind to', parseInt) - .option('-q, --quiet', 'Prevent all logging except errors') + .option('-q, --quiet', 'Deprecated, set logging level in your configuration') .option('-Q, --silent', 'Prevent all logging') .option('--verbose', 'Turns on verbose logging') .option('-H, --host ', 'The host to bind to') - .option('-l, --log-file ', 'The file to log to') + .option( + '-l, --log-file ', + 'Deprecated, set logging file destination in your configuration' + ) .option( '--plugin-dir ', 'A path to scan for plugins, this can be specified multiple ' + @@ -204,7 +216,8 @@ export default function (program) { cliArgs: { dev: !!opts.dev, envName: unknownOptions.env ? unknownOptions.env.name : undefined, - quiet: !!opts.quiet, + // no longer supported + quiet: !!opts.quiet, // no longer supported silent: !!opts.silent, watch: !!opts.watch, runExamples: !!opts.runExamples, diff --git a/src/core/server/config/deprecation/core_deprecations.test.ts b/src/core/server/config/deprecation/core_deprecations.test.ts index 0947b183c05e2..98b0fac2d547e 100644 --- a/src/core/server/config/deprecation/core_deprecations.test.ts +++ b/src/core/server/config/deprecation/core_deprecations.test.ts @@ -349,7 +349,7 @@ describe('core deprecations', () => { }); expect(messages).toMatchInlineSnapshot(` Array [ - "\\"logging.quiet\\", \\"logging.silent\\" and \\"logging.verbose\\" have been deprecated and will be removed in 8.0. Moving forward, you can use \\"logging.root.level\\" in your logging configuration. Levels \\"error\\", \\"off\\" and \\"all\\" are equivalent to \\"quiet\\", \\"silent\\" and \\"verbose\\". For more details, see https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", + "\\"logging.quiet\\" has been deprecated and will be removed in 8.0. Moving forward, you can use \\"logging.root.level:error\\" in your logging configuration. ", ] `); }); @@ -359,7 +359,7 @@ describe('core deprecations', () => { }); expect(messages).toMatchInlineSnapshot(` Array [ - "\\"logging.quiet\\", \\"logging.silent\\" and \\"logging.verbose\\" have been deprecated and will be removed in 8.0. Moving forward, you can use \\"logging.root.level\\" in your logging configuration. Levels \\"error\\", \\"off\\" and \\"all\\" are equivalent to \\"quiet\\", \\"silent\\" and \\"verbose\\". For more details, see https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", + "\\"logging.silent\\" has been deprecated and will be removed in 8.0. Moving forward, you can use \\"logging.root.level:off\\" in your logging configuration. ", ] `); }); @@ -369,7 +369,7 @@ describe('core deprecations', () => { }); expect(messages).toMatchInlineSnapshot(` Array [ - "\\"logging.quiet\\", \\"logging.silent\\" and \\"logging.verbose\\" have been deprecated and will be removed in 8.0. Moving forward, you can use \\"logging.root.level\\" in your logging configuration. Levels \\"error\\", \\"off\\" and \\"all\\" are equivalent to \\"quiet\\", \\"silent\\" and \\"verbose\\". For more details, see https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", + "\\"logging.verbose\\" has been deprecated and will be removed in 8.0. Moving forward, you can use \\"logging.root.level:all\\" in your logging configuration. ", ] `); }); diff --git a/src/core/server/config/deprecation/core_deprecations.ts b/src/core/server/config/deprecation/core_deprecations.ts index 02a1ec87835f9..6070aa263075b 100644 --- a/src/core/server/config/deprecation/core_deprecations.ts +++ b/src/core/server/config/deprecation/core_deprecations.ts @@ -151,17 +151,31 @@ const destLoggingDeprecation: ConfigDeprecation = (settings, fromPath, log) => { return settings; }; -const quietSilentVerboseLoggingDeprecation: ConfigDeprecation = (settings, fromPath, log) => { - if ( - has(settings, 'logging.quiet') || - has(settings, 'logging.silent') || - has(settings, 'logging.verbose') - ) { +const quietLoggingDeprecation: ConfigDeprecation = (settings, fromPath, log) => { + if (has(settings, 'logging.quiet')) { log( - '"logging.quiet", "logging.silent" and "logging.verbose" have been deprecated and will be removed ' + - 'in 8.0. Moving forward, you can use "logging.root.level" in your logging configuration. ' + - 'Levels "error", "off" and "all" are equivalent to "quiet", "silent" and "verbose". For more details, see ' + - 'https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.' + '"logging.quiet" has been deprecated and will be removed ' + + 'in 8.0. Moving forward, you can use "logging.root.level:error" in your logging configuration. ' + ); + } + return settings; +}; + +const silentLoggingDeprecation: ConfigDeprecation = (settings, fromPath, log) => { + if (has(settings, 'logging.silent')) { + log( + '"logging.silent" has been deprecated and will be removed ' + + 'in 8.0. Moving forward, you can use "logging.root.level:off" in your logging configuration. ' + ); + } + return settings; +}; + +const verboseLoggingDeprecation: ConfigDeprecation = (settings, fromPath, log) => { + if (has(settings, 'logging.verbose')) { + log( + '"logging.verbose" has been deprecated and will be removed ' + + 'in 8.0. Moving forward, you can use "logging.root.level:all" in your logging configuration. ' ); } return settings; @@ -235,7 +249,9 @@ export const coreDeprecationProvider: ConfigDeprecationProvider = ({ rename, unu requestLoggingEventDeprecation, timezoneLoggingDeprecation, destLoggingDeprecation, - quietSilentVerboseLoggingDeprecation, + quietLoggingDeprecation, + silentLoggingDeprecation, + verboseLoggingDeprecation, jsonLoggingDeprecation, logRotateDeprecation, ]; diff --git a/src/core/server/config/integration_tests/config_deprecation.test.ts b/src/core/server/config/integration_tests/config_deprecation.test.ts index 84f1025a48dd3..5b672774c515a 100644 --- a/src/core/server/config/integration_tests/config_deprecation.test.ts +++ b/src/core/server/config/integration_tests/config_deprecation.test.ts @@ -31,7 +31,7 @@ describe('configuration deprecations', () => { const logs = loggingSystemMock.collect(mockLoggingSystem); expect(logs.warn.flat()).toMatchInlineSnapshot(` Array [ - "\\"logging.quiet\\", \\"logging.silent\\" and \\"logging.verbose\\" have been deprecated and will be removed in 8.0. Moving forward, you can use \\"logging.root.level\\" in your logging configuration. Levels \\"error\\", \\"off\\" and \\"all\\" are equivalent to \\"quiet\\", \\"silent\\" and \\"verbose\\". For more details, see https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", + "\\"logging.silent\\" has been deprecated and will be removed in 8.0. Moving forward, you can use \\"logging.root.level:off\\" in your logging configuration. ", ] `); }); @@ -51,7 +51,7 @@ describe('configuration deprecations', () => { Array [ "optimize.lazy is deprecated and is no longer used", "optimize.lazyPort is deprecated and is no longer used", - "\\"logging.quiet\\", \\"logging.silent\\" and \\"logging.verbose\\" have been deprecated and will be removed in 8.0. Moving forward, you can use \\"logging.root.level\\" in your logging configuration. Levels \\"error\\", \\"off\\" and \\"all\\" are equivalent to \\"quiet\\", \\"silent\\" and \\"verbose\\". For more details, see https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", + "\\"logging.silent\\" has been deprecated and will be removed in 8.0. Moving forward, you can use \\"logging.root.level:off\\" in your logging configuration. ", ] `); }); diff --git a/src/core/test_helpers/kbn_server.ts b/src/core/test_helpers/kbn_server.ts index 14f614643ac9f..225e28cbf911c 100644 --- a/src/core/test_helpers/kbn_server.ts +++ b/src/core/test_helpers/kbn_server.ts @@ -60,7 +60,7 @@ export function createRootWithSettings( configs: [], cliArgs: { dev: false, - quiet: false, + // quiet: false, silent: false, watch: false, basePath: false, From b9011ffb6d89034a57fdb0e779818536aeed2a16 Mon Sep 17 00:00:00 2001 From: Christiane Heiligers Date: Mon, 15 Mar 2021 08:39:07 -0700 Subject: [PATCH 08/16] Only log logging.json deprecation warnings when not in dev and only set legacy logging level when not opted in to KP logging --- packages/kbn-legacy-logging/src/schema.ts | 10 +++------- src/cli/serve/serve.js | 14 ++++++-------- .../server/config/deprecation/core_deprecations.ts | 12 +++++++----- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/packages/kbn-legacy-logging/src/schema.ts b/packages/kbn-legacy-logging/src/schema.ts index 3233813bbd545..ceed351f9b5c6 100644 --- a/packages/kbn-legacy-logging/src/schema.ts +++ b/packages/kbn-legacy-logging/src/schema.ts @@ -18,8 +18,8 @@ const HANDLED_IN_KIBANA_PLATFORM = Joi.any().description( * Set up logging from the platform logging instead */ export interface LegacyLoggingConfig { - silent: boolean; // support for cli args - quiet?: boolean; // deprecated + silent: boolean; + quiet?: boolean; verbose: boolean; events: Record; dest: string; @@ -33,7 +33,7 @@ export interface LegacyLoggingConfig { pollingInterval: number; usePolling: boolean; pollingPolicyTestTimeout?: number; - }; // all deprecated + }; } export const legacyLoggingConfigSchema = Joi.object() @@ -43,7 +43,6 @@ export const legacyLoggingConfigSchema = Joi.object() root: HANDLED_IN_KIBANA_PLATFORM, silent: Joi.boolean().default(false), - // deprecated quiet: Joi.boolean().when('silent', { is: true, then: Joi.boolean().default(true).valid(true), @@ -55,17 +54,14 @@ export const legacyLoggingConfigSchema = Joi.object() otherwise: Joi.boolean().default(false), }), events: Joi.any().default({}), - // deprecated dest: Joi.string().default('stdout'), filter: Joi.any().default({}), - // deprecated json: Joi.boolean().when('dest', { is: 'stdout', then: Joi.boolean().default(!process.stdout.isTTY), otherwise: Joi.boolean().default(true), }), timezone: Joi.string(), - // deprecated rotate: Joi.object() .keys({ enabled: Joi.boolean().default(false), diff --git a/src/cli/serve/serve.js b/src/cli/serve/serve.js index b0646b841b1f2..681c14426f193 100644 --- a/src/cli/serve/serve.js +++ b/src/cli/serve/serve.js @@ -112,19 +112,17 @@ function applyConfigOverrides(rawConfig, opts, extraCliOptions) { if (opts.elasticsearch) set('elasticsearch.hosts', opts.elasticsearch.split(',')); if (opts.port) set('server.port', opts.port); if (opts.host) set('server.host', opts.host); - // if (opts.quiet) set('logging.quiet', true); // deprecated - - // retain support for cli flag `--silent` if (opts.silent) { - // set('logging.level', 'off') && set('logging.root.level', 'off'); set('logging.silent', true) && set('logging.root.level', 'off'); } - // retain support for cli flag `--verbose` if (opts.verbose) { - // set('logging.level', 'all') && set('logging.root.level', 'all'); - set('logging.verbose', true) && set('logging.root.level', 'all'); + // Only set logging.verbose to true when KP logging isn't configured. + if (!has('rawConfig.logging.root.appenders')) { + set('logging.verbose', true); + } else { + set('logging.root.level', 'all'); + } } - // if (opts.logFile) set('logging.dest', opts.logFile); // deprecated set('plugins.scanDirs', _.compact([].concat(get('plugins.scanDirs'), opts.pluginDir))); set('plugins.paths', _.compact([].concat(get('plugins.paths'), opts.pluginPath))); diff --git a/src/core/server/config/deprecation/core_deprecations.ts b/src/core/server/config/deprecation/core_deprecations.ts index 6070aa263075b..2a80d30ce4ce7 100644 --- a/src/core/server/config/deprecation/core_deprecations.ts +++ b/src/core/server/config/deprecation/core_deprecations.ts @@ -182,11 +182,13 @@ const verboseLoggingDeprecation: ConfigDeprecation = (settings, fromPath, log) = }; const jsonLoggingDeprecation: ConfigDeprecation = (settings, fromPath, log) => { - if (has(settings, 'logging.json')) { + if (has(settings, 'logging.json') && settings.env !== 'development') { log( '"logging.json" has been deprecated and will be removed ' + 'in 8.0. To specify log message format moving forward, ' + - 'you can configure the "appender.layout" property for every custom appender in your logging configuration. There is currently no default layout for custom appenders and each one must be declared explicitly. For more details, see ' + + 'you can configure the "appender.layout" property for every custom appender in your logging configuration.' + + 'There is currently no default layout for custom appenders and each one must be declared explicitly. ' + + 'For more details, see ' + 'https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.' ); } @@ -202,9 +204,9 @@ const logRotateDeprecation: ConfigDeprecation = (settings, fromPath, log) => { has(settings, 'logging.rotate.keepFiles') ) { log( - '"logging.rotate" and sub-options have been deprecated and will be removed in 8.0. Moving forward, you can enabled ' + - 'log rotation using the "rolling-file" appender for a context in your logging configuration. ' + - 'For more details, see ' + + '"logging.rotate" and sub-options have been deprecated and will be removed in 8.0. ' + + 'Moving forward, you can enabled log rotation using the "rolling-file" appender for a context ' + + 'in your logging configuration. For more details, see ' + 'https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx#rolling-file-appender' ); } From 1adb68f0dbcf0a24eedd11df11c746196edf52df Mon Sep 17 00:00:00 2001 From: Christiane Heiligers Date: Mon, 15 Mar 2021 08:53:11 -0700 Subject: [PATCH 09/16] Updates snapshot --- src/core/server/config/deprecation/core_deprecations.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/server/config/deprecation/core_deprecations.test.ts b/src/core/server/config/deprecation/core_deprecations.test.ts index 98b0fac2d547e..132716dcb7c75 100644 --- a/src/core/server/config/deprecation/core_deprecations.test.ts +++ b/src/core/server/config/deprecation/core_deprecations.test.ts @@ -382,7 +382,7 @@ describe('core deprecations', () => { }); expect(messages).toMatchInlineSnapshot(` Array [ - "\\"logging.json\\" has been deprecated and will be removed in 8.0. To specify log message format moving forward, you can configure the \\"appender.layout\\" property for every custom appender in your logging configuration. There is currently no default layout for custom appenders and each one must be declared explicitly. For more details, see https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", + "\\"logging.json\\" has been deprecated and will be removed in 8.0. To specify log message format moving forward, you can configure the \\"appender.layout\\" property for every custom appender in your logging configuration.There is currently no default layout for custom appenders and each one must be declared explicitly. For more details, see https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", ] `); }); From 63e4fe65b38b19aaf8ff7f9acb5313a18102c7a4 Mon Sep 17 00:00:00 2001 From: Christiane Heiligers Date: Mon, 15 Mar 2021 10:40:09 -0700 Subject: [PATCH 10/16] Removes server logs from legacy --- src/legacy/server/kbn_server.js | 16 +--------------- src/legacy/server/logging/index.js | 6 ++---- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/src/legacy/server/kbn_server.js b/src/legacy/server/kbn_server.js index 55593d13d4687..7b8dcf46b43ca 100644 --- a/src/legacy/server/kbn_server.js +++ b/src/legacy/server/kbn_server.js @@ -98,20 +98,13 @@ export default class KbnServer { async listen() { await this.ready(); - const { server, config } = this; + const { server } = this; if (process.env.isDevCliChild) { // help parent process know when we are ready process.send(['SERVER_LISTENING']); } - server.log( - ['listening', 'info'], - `Server running at ${server.info.uri}${ - config.get('server.rewriteBasePath') ? config.get('server.basePath') : '' - }` - ); - return server; } @@ -137,13 +130,6 @@ export default class KbnServer { const loggingConfig = config.get('logging'); const opsConfig = config.get('ops'); - const subset = { - ops: opsConfig, - logging: loggingConfig, - }; - const plain = JSON.stringify(subset, null, 2); - this.server.log(['info', 'config'], 'New logging configuration:\n' + plain); - reconfigureLogging(this.server, loggingConfig, opsConfig.interval); } } diff --git a/src/legacy/server/logging/index.js b/src/legacy/server/logging/index.js index 0a3d7e3e0a5a9..4d9e1a50a08c6 100644 --- a/src/legacy/server/logging/index.js +++ b/src/legacy/server/logging/index.js @@ -6,12 +6,10 @@ * Side Public License, v 1. */ -import { setupLogging, setupLoggingRotate, attachMetaData } from '@kbn/legacy-logging'; +import { setupLogging, setupLoggingRotate } from '@kbn/legacy-logging'; export async function loggingMixin(kbnServer, server, config) { - server.decorate('server', 'logWithMetadata', (tags, message, metadata = {}) => { - server.log(tags, attachMetaData(message, metadata)); - }); + server.decorate('server', 'logWithMetadata'); const loggingConfig = config.get('logging'); const opsInterval = config.get('ops.interval'); From f87ae2eaeb75fa2e679c7197228cea22184b5fe8 Mon Sep 17 00:00:00 2001 From: Christiane Heiligers Date: Mon, 15 Mar 2021 10:52:03 -0700 Subject: [PATCH 11/16] snapshot update --- src/core/server/config/deprecation/core_deprecations.test.ts | 2 +- src/core/server/config/deprecation/core_deprecations.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/server/config/deprecation/core_deprecations.test.ts b/src/core/server/config/deprecation/core_deprecations.test.ts index 132716dcb7c75..98b0fac2d547e 100644 --- a/src/core/server/config/deprecation/core_deprecations.test.ts +++ b/src/core/server/config/deprecation/core_deprecations.test.ts @@ -382,7 +382,7 @@ describe('core deprecations', () => { }); expect(messages).toMatchInlineSnapshot(` Array [ - "\\"logging.json\\" has been deprecated and will be removed in 8.0. To specify log message format moving forward, you can configure the \\"appender.layout\\" property for every custom appender in your logging configuration.There is currently no default layout for custom appenders and each one must be declared explicitly. For more details, see https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", + "\\"logging.json\\" has been deprecated and will be removed in 8.0. To specify log message format moving forward, you can configure the \\"appender.layout\\" property for every custom appender in your logging configuration. There is currently no default layout for custom appenders and each one must be declared explicitly. For more details, see https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", ] `); }); diff --git a/src/core/server/config/deprecation/core_deprecations.ts b/src/core/server/config/deprecation/core_deprecations.ts index 2a80d30ce4ce7..29f64493be996 100644 --- a/src/core/server/config/deprecation/core_deprecations.ts +++ b/src/core/server/config/deprecation/core_deprecations.ts @@ -186,7 +186,7 @@ const jsonLoggingDeprecation: ConfigDeprecation = (settings, fromPath, log) => { log( '"logging.json" has been deprecated and will be removed ' + 'in 8.0. To specify log message format moving forward, ' + - 'you can configure the "appender.layout" property for every custom appender in your logging configuration.' + + 'you can configure the "appender.layout" property for every custom appender in your logging configuration. ' + 'There is currently no default layout for custom appenders and each one must be declared explicitly. ' + 'For more details, see ' + 'https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.' From 84cf8fe2009a99a9838d874fa4615d9e3ca28fd6 Mon Sep 17 00:00:00 2001 From: Christiane Heiligers Date: Tue, 16 Mar 2021 16:44:49 -0700 Subject: [PATCH 12/16] Handles initial review comments --- docs/migration/migrate_8_0.asciidoc | 11 +++++------ .../config/deprecation/core_deprecations.test.ts | 14 +++++++------- .../server/config/deprecation/core_deprecations.ts | 6 +++--- src/core/test_helpers/kbn_server.ts | 1 - src/legacy/server/logging/index.js | 3 ++- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/docs/migration/migrate_8_0.asciidoc b/docs/migration/migrate_8_0.asciidoc index fc4690703892b..a88b3975c83c1 100644 --- a/docs/migration/migrate_8_0.asciidoc +++ b/docs/migration/migrate_8_0.asciidoc @@ -103,9 +103,8 @@ logging: fileName: /var/log/kibana.log layout: type: pattern - loggers: - - name: plugins.myPlugin - appenders: [file] + root: + appenders: [default, file] ------------------- [float] @@ -193,7 +192,6 @@ logging: type: console layout: type: pattern - appenders: custom_json: type: console layout: @@ -201,8 +199,9 @@ logging: loggers: - name: plugins.myPlugin appenders: [custom_console] - - name: plugins.myOtherPlugin - appenders: [custom_json] + root: + appenders: [default, custom_json] + level: warn ------------------- [float] diff --git a/src/core/server/config/deprecation/core_deprecations.test.ts b/src/core/server/config/deprecation/core_deprecations.test.ts index 98b0fac2d547e..21c67cea426e2 100644 --- a/src/core/server/config/deprecation/core_deprecations.test.ts +++ b/src/core/server/config/deprecation/core_deprecations.test.ts @@ -326,7 +326,7 @@ describe('core deprecations', () => { }); expect(messages).toMatchInlineSnapshot(` Array [ - "\\"logging.dest\\" has been deprecated and will be removed in 8.0. To set the destination moving forward, you can use the \\"console\\" appender in your logging configuration or define a custom one. For more details, see https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", + "\\"logging.dest\\" has been deprecated and will be removed in 8.0. To set the destination moving forward, you can use the \\"console\\" appender in your logging configuration or define a custom one. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", ] `); }); @@ -336,7 +336,7 @@ describe('core deprecations', () => { }); expect(messages).toMatchInlineSnapshot(` Array [ - "\\"logging.dest\\" has been deprecated and will be removed in 8.0. To set the destination moving forward, you can use the \\"console\\" appender in your logging configuration or define a custom one. For more details, see https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", + "\\"logging.dest\\" has been deprecated and will be removed in 8.0. To set the destination moving forward, you can use the \\"console\\" appender in your logging configuration or define a custom one. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", ] `); }); @@ -382,7 +382,7 @@ describe('core deprecations', () => { }); expect(messages).toMatchInlineSnapshot(` Array [ - "\\"logging.json\\" has been deprecated and will be removed in 8.0. To specify log message format moving forward, you can configure the \\"appender.layout\\" property for every custom appender in your logging configuration. There is currently no default layout for custom appenders and each one must be declared explicitly. For more details, see https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", + "\\"logging.json\\" has been deprecated and will be removed in 8.0. To specify log message format moving forward, you can configure the \\"appender.layout\\" property for every custom appender in your logging configuration. There is currently no default layout for custom appenders and each one must be declared explicitly. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", ] `); }); @@ -395,7 +395,7 @@ describe('core deprecations', () => { }); expect(messages).toMatchInlineSnapshot(` Array [ - "\\"logging.rotate\\" and sub-options have been deprecated and will be removed in 8.0. Moving forward, you can enabled log rotation using the \\"rolling-file\\" appender for a context in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx#rolling-file-appender", + "\\"logging.rotate\\" and sub-options have been deprecated and will be removed in 8.0. Moving forward, you can enable log rotation using the \\"rolling-file\\" appender for a logger in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx#rolling-file-appender", ] `); }); @@ -406,7 +406,7 @@ describe('core deprecations', () => { }); expect(messages).toMatchInlineSnapshot(` Array [ - "\\"logging.rotate\\" and sub-options have been deprecated and will be removed in 8.0. Moving forward, you can enabled log rotation using the \\"rolling-file\\" appender for a context in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx#rolling-file-appender", + "\\"logging.rotate\\" and sub-options have been deprecated and will be removed in 8.0. Moving forward, you can enable log rotation using the \\"rolling-file\\" appender for a logger in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx#rolling-file-appender", ] `); }); @@ -417,7 +417,7 @@ describe('core deprecations', () => { }); expect(messages).toMatchInlineSnapshot(` Array [ - "\\"logging.rotate\\" and sub-options have been deprecated and will be removed in 8.0. Moving forward, you can enabled log rotation using the \\"rolling-file\\" appender for a context in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx#rolling-file-appender", + "\\"logging.rotate\\" and sub-options have been deprecated and will be removed in 8.0. Moving forward, you can enable log rotation using the \\"rolling-file\\" appender for a logger in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx#rolling-file-appender", ] `); }); @@ -428,7 +428,7 @@ describe('core deprecations', () => { }); expect(messages).toMatchInlineSnapshot(` Array [ - "\\"logging.rotate\\" and sub-options have been deprecated and will be removed in 8.0. Moving forward, you can enabled log rotation using the \\"rolling-file\\" appender for a context in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx#rolling-file-appender", + "\\"logging.rotate\\" and sub-options have been deprecated and will be removed in 8.0. Moving forward, you can enable log rotation using the \\"rolling-file\\" appender for a logger in your logging configuration. For more details, see https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx#rolling-file-appender", ] `); }); diff --git a/src/core/server/config/deprecation/core_deprecations.ts b/src/core/server/config/deprecation/core_deprecations.ts index 29f64493be996..6875165275d5d 100644 --- a/src/core/server/config/deprecation/core_deprecations.ts +++ b/src/core/server/config/deprecation/core_deprecations.ts @@ -145,7 +145,7 @@ const destLoggingDeprecation: ConfigDeprecation = (settings, fromPath, log) => { '"logging.dest" has been deprecated and will be removed ' + 'in 8.0. To set the destination moving forward, you can use the "console" appender ' + 'in your logging configuration or define a custom one. For more details, see ' + - 'https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.' + 'https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx.' ); } return settings; @@ -189,7 +189,7 @@ const jsonLoggingDeprecation: ConfigDeprecation = (settings, fromPath, log) => { 'you can configure the "appender.layout" property for every custom appender in your logging configuration. ' + 'There is currently no default layout for custom appenders and each one must be declared explicitly. ' + 'For more details, see ' + - 'https://github/elastic/kibana/blob/master/src/core/server/logging/README.mdx.' + 'https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx.' ); } return settings; @@ -205,7 +205,7 @@ const logRotateDeprecation: ConfigDeprecation = (settings, fromPath, log) => { ) { log( '"logging.rotate" and sub-options have been deprecated and will be removed in 8.0. ' + - 'Moving forward, you can enabled log rotation using the "rolling-file" appender for a context ' + + 'Moving forward, you can enable log rotation using the "rolling-file" appender for a logger ' + 'in your logging configuration. For more details, see ' + 'https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx#rolling-file-appender' ); diff --git a/src/core/test_helpers/kbn_server.ts b/src/core/test_helpers/kbn_server.ts index 225e28cbf911c..5e274712ad3a7 100644 --- a/src/core/test_helpers/kbn_server.ts +++ b/src/core/test_helpers/kbn_server.ts @@ -60,7 +60,6 @@ export function createRootWithSettings( configs: [], cliArgs: { dev: false, - // quiet: false, silent: false, watch: false, basePath: false, diff --git a/src/legacy/server/logging/index.js b/src/legacy/server/logging/index.js index 4d9e1a50a08c6..628ba3e101509 100644 --- a/src/legacy/server/logging/index.js +++ b/src/legacy/server/logging/index.js @@ -9,7 +9,8 @@ import { setupLogging, setupLoggingRotate } from '@kbn/legacy-logging'; export async function loggingMixin(kbnServer, server, config) { - server.decorate('server', 'logWithMetadata'); + // eslint-disable-next-line no-unused-vars + server.decorate('server', 'logWithMetadata', (tags, message, metadata = {}) => {}); const loggingConfig = config.get('logging'); const opsInterval = config.get('ops.interval'); From f1e901d9c415a2545d0efed22f7bb2f9943bde64 Mon Sep 17 00:00:00 2001 From: Christiane Heiligers Date: Tue, 16 Mar 2021 17:10:00 -0700 Subject: [PATCH 13/16] Adds deprecation warnings for legacy logging.event.log and logging.event.error configuration --- .../deprecation/core_deprecations.test.ts | 47 ++++++++++--------- .../config/deprecation/core_deprecations.ts | 22 +++++++++ 2 files changed, 48 insertions(+), 21 deletions(-) diff --git a/src/core/server/config/deprecation/core_deprecations.test.ts b/src/core/server/config/deprecation/core_deprecations.test.ts index 21c67cea426e2..69ab35829c87c 100644 --- a/src/core/server/config/deprecation/core_deprecations.test.ts +++ b/src/core/server/config/deprecation/core_deprecations.test.ts @@ -248,13 +248,6 @@ describe('core deprecations', () => { ] `); }); - - it('does not warn when other events are configured', () => { - const { messages } = applyCoreDeprecations({ - logging: { events: { log: '*' } }, - }); - expect(messages).toEqual([]); - }); }); describe('logging.events.request and logging.events.response', () => { @@ -290,13 +283,6 @@ describe('core deprecations', () => { ] `); }); - - it('does not warn when other events are configured', () => { - const { messages } = applyCoreDeprecations({ - logging: { events: { log: '*' } }, - }); - expect(messages).toEqual([]); - }); }); describe('logging.timezone', () => { @@ -310,13 +296,6 @@ describe('core deprecations', () => { ] `); }); - - it('does not warn when other events are configured', () => { - const { messages } = applyCoreDeprecations({ - logging: { events: { log: '*' } }, - }); - expect(messages).toEqual([]); - }); }); describe('logging.dest', () => { @@ -433,4 +412,30 @@ describe('core deprecations', () => { `); }); }); + + describe('logging.events.log', () => { + it('warns when events.log is used', () => { + const { messages } = applyCoreDeprecations({ + logging: { events: { log: ['info'] } }, + }); + expect(messages).toMatchInlineSnapshot(` + Array [ + "\\"logging.events.log\\" has been deprecated and will be removed in 8.0. Moving forward, you can use \\"logging.root.level\\" in your logging configuration. ", + ] + `); + }); + }); + + describe('logging.events.error', () => { + it('warns when events.error is used', () => { + const { messages } = applyCoreDeprecations({ + logging: { events: { error: ['some error'] } }, + }); + expect(messages).toMatchInlineSnapshot(` + Array [ + "\\"logging.events.error\\" has been deprecated and will be removed in 8.0. Moving forward, you can use \\"logging.root.level: error\\" in your logging configuration. ", + ] + `); + }); + }); }); diff --git a/src/core/server/config/deprecation/core_deprecations.ts b/src/core/server/config/deprecation/core_deprecations.ts index 6875165275d5d..c3584df5a8c64 100644 --- a/src/core/server/config/deprecation/core_deprecations.ts +++ b/src/core/server/config/deprecation/core_deprecations.ts @@ -213,6 +213,26 @@ const logRotateDeprecation: ConfigDeprecation = (settings, fromPath, log) => { return settings; }; +const logEventsLogDeprecation: ConfigDeprecation = (settings, fromPath, log) => { + if (has(settings, 'logging.events.log')) { + log( + '"logging.events.log" has been deprecated and will be removed ' + + 'in 8.0. Moving forward, you can use "logging.root.level" in your logging configuration. ' + ); + } + return settings; +}; + +const logEventsErrorDeprecation: ConfigDeprecation = (settings, fromPath, log) => { + if (has(settings, 'logging.events.error')) { + log( + '"logging.events.error" has been deprecated and will be removed ' + + 'in 8.0. Moving forward, you can use "logging.root.level: error" in your logging configuration. ' + ); + } + return settings; +}; + export const coreDeprecationProvider: ConfigDeprecationProvider = ({ rename, unusedFromRoot }) => [ unusedFromRoot('savedObjects.indexCheckTimeout'), unusedFromRoot('server.xsrf.token'), @@ -256,4 +276,6 @@ export const coreDeprecationProvider: ConfigDeprecationProvider = ({ rename, unu verboseLoggingDeprecation, jsonLoggingDeprecation, logRotateDeprecation, + logEventsLogDeprecation, + logEventsErrorDeprecation, ]; From 58aeff3318c6776df9c07f66be8e920b174362c8 Mon Sep 17 00:00:00 2001 From: Christiane Heiligers Date: Tue, 16 Mar 2021 18:24:51 -0700 Subject: [PATCH 14/16] Removes duplicate comment --- src/cli/serve/serve.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli/serve/serve.js b/src/cli/serve/serve.js index 681c14426f193..da4ca8cf2eace 100644 --- a/src/cli/serve/serve.js +++ b/src/cli/serve/serve.js @@ -215,7 +215,7 @@ export default function (program) { dev: !!opts.dev, envName: unknownOptions.env ? unknownOptions.env.name : undefined, // no longer supported - quiet: !!opts.quiet, // no longer supported + quiet: !!opts.quiet, silent: !!opts.silent, watch: !!opts.watch, runExamples: !!opts.runExamples, From 78508777f9638aa93c0d0362802f988ec890500c Mon Sep 17 00:00:00 2001 From: Christiane Heiligers Date: Wed, 17 Mar 2021 09:03:24 -0700 Subject: [PATCH 15/16] Deprecates logging.filter, addresses review comments --- docs/migration/migrate_8_0.asciidoc | 5 ++-- packages/kbn-legacy-logging/src/schema.ts | 2 +- src/cli/serve/serve.js | 4 ++-- .../deprecation/core_deprecations.test.ts | 24 +++++++++++++++++++ .../config/deprecation/core_deprecations.ts | 17 +++++++------ src/legacy/server/kbn_server.d.ts | 1 - src/legacy/server/logging/index.js | 3 --- 7 files changed, 39 insertions(+), 17 deletions(-) diff --git a/docs/migration/migrate_8_0.asciidoc b/docs/migration/migrate_8_0.asciidoc index a88b3975c83c1..52d1d63ce0653 100644 --- a/docs/migration/migrate_8_0.asciidoc +++ b/docs/migration/migrate_8_0.asciidoc @@ -88,9 +88,8 @@ See https://github.com/elastic/kibana/pull/87939 for more details. [source,yaml] ------------------- logging: - loggers: - - name: plugins.myPlugin - appenders: [console] + root: + appenders: [default, console] ------------------- To send logs to `file` with a given file path, you should define a custom appender with `type:file`: diff --git a/packages/kbn-legacy-logging/src/schema.ts b/packages/kbn-legacy-logging/src/schema.ts index ceed351f9b5c6..76d7381ee8728 100644 --- a/packages/kbn-legacy-logging/src/schema.ts +++ b/packages/kbn-legacy-logging/src/schema.ts @@ -19,7 +19,7 @@ const HANDLED_IN_KIBANA_PLATFORM = Joi.any().description( */ export interface LegacyLoggingConfig { silent: boolean; - quiet?: boolean; + quiet: boolean; verbose: boolean; events: Record; dest: string; diff --git a/src/cli/serve/serve.js b/src/cli/serve/serve.js index da4ca8cf2eace..fb24fa2cf262f 100644 --- a/src/cli/serve/serve.js +++ b/src/cli/serve/serve.js @@ -51,7 +51,6 @@ function applyConfigOverrides(rawConfig, opts, extraCliOptions) { const get = _.partial(_.get, rawConfig); const has = _.partial(_.has, rawConfig); const merge = _.partial(_.merge, rawConfig); - if (opts.oss) { delete rawConfig.xpack; } @@ -113,7 +112,8 @@ function applyConfigOverrides(rawConfig, opts, extraCliOptions) { if (opts.port) set('server.port', opts.port); if (opts.host) set('server.host', opts.host); if (opts.silent) { - set('logging.silent', true) && set('logging.root.level', 'off'); + set('logging.silent', true); + set('logging.root.level', 'off'); } if (opts.verbose) { // Only set logging.verbose to true when KP logging isn't configured. diff --git a/src/core/server/config/deprecation/core_deprecations.test.ts b/src/core/server/config/deprecation/core_deprecations.test.ts index 69ab35829c87c..be8ad736d42dd 100644 --- a/src/core/server/config/deprecation/core_deprecations.test.ts +++ b/src/core/server/config/deprecation/core_deprecations.test.ts @@ -438,4 +438,28 @@ describe('core deprecations', () => { `); }); }); + + describe('logging.filter', () => { + it('warns when filter.cookie is used', () => { + const { messages } = applyCoreDeprecations({ + logging: { filter: { cookie: 'none' } }, + }); + expect(messages).toMatchInlineSnapshot(` + Array [ + "\\"logging.filter\\" has been deprecated and will be removed in 8.0. ", + ] + `); + }); + + it('warns when filter.authorization is used', () => { + const { messages } = applyCoreDeprecations({ + logging: { filter: { authorization: 'none' } }, + }); + expect(messages).toMatchInlineSnapshot(` + Array [ + "\\"logging.filter\\" has been deprecated and will be removed in 8.0. ", + ] + `); + }); + }); }); diff --git a/src/core/server/config/deprecation/core_deprecations.ts b/src/core/server/config/deprecation/core_deprecations.ts index c3584df5a8c64..5a0a22afa91cf 100644 --- a/src/core/server/config/deprecation/core_deprecations.ts +++ b/src/core/server/config/deprecation/core_deprecations.ts @@ -196,13 +196,7 @@ const jsonLoggingDeprecation: ConfigDeprecation = (settings, fromPath, log) => { }; const logRotateDeprecation: ConfigDeprecation = (settings, fromPath, log) => { - if ( - has(settings, 'logging.rotate.enabled') || - has(settings, 'logging.rotate.usePolling') || - has(settings, 'logging.rotate.pollingInterval') || - has(settings, 'logging.rotate.everyBytes') || - has(settings, 'logging.rotate.keepFiles') - ) { + if (has(settings, 'logging.rotate')) { log( '"logging.rotate" and sub-options have been deprecated and will be removed in 8.0. ' + 'Moving forward, you can enable log rotation using the "rolling-file" appender for a logger ' + @@ -233,6 +227,14 @@ const logEventsErrorDeprecation: ConfigDeprecation = (settings, fromPath, log) = return settings; }; +const logFilterDeprecation: ConfigDeprecation = (settings, fromPath, log) => { + if (has(settings, 'logging.filter')) { + // usage: logging.filter.cookie=none or logging.filter.authorization=none + log('"logging.filter" has been deprecated and will be removed ' + 'in 8.0. '); + } + return settings; +}; + export const coreDeprecationProvider: ConfigDeprecationProvider = ({ rename, unusedFromRoot }) => [ unusedFromRoot('savedObjects.indexCheckTimeout'), unusedFromRoot('server.xsrf.token'), @@ -278,4 +280,5 @@ export const coreDeprecationProvider: ConfigDeprecationProvider = ({ rename, unu logRotateDeprecation, logEventsLogDeprecation, logEventsErrorDeprecation, + logFilterDeprecation, ]; diff --git a/src/legacy/server/kbn_server.d.ts b/src/legacy/server/kbn_server.d.ts index 57ecaeab209ed..3fe0f5899668f 100644 --- a/src/legacy/server/kbn_server.d.ts +++ b/src/legacy/server/kbn_server.d.ts @@ -33,7 +33,6 @@ declare module 'hapi' { interface Server { config: () => KibanaConfig; - logWithMetadata: (tags: string[], message: string, meta: Record) => void; newPlatform: KbnServer['newPlatform']; } } diff --git a/src/legacy/server/logging/index.js b/src/legacy/server/logging/index.js index 628ba3e101509..1b2ae59f4aa00 100644 --- a/src/legacy/server/logging/index.js +++ b/src/legacy/server/logging/index.js @@ -9,9 +9,6 @@ import { setupLogging, setupLoggingRotate } from '@kbn/legacy-logging'; export async function loggingMixin(kbnServer, server, config) { - // eslint-disable-next-line no-unused-vars - server.decorate('server', 'logWithMetadata', (tags, message, metadata = {}) => {}); - const loggingConfig = config.get('logging'); const opsInterval = config.get('ops.interval'); From 45971d93fdf6b2d69006e3651186b1bc94f19f9e Mon Sep 17 00:00:00 2001 From: Christiane Heiligers Date: Wed, 17 Mar 2021 13:02:51 -0700 Subject: [PATCH 16/16] Updates deprecation warnings and snapshots --- src/cli/serve/serve.js | 8 ++++---- .../server/config/deprecation/core_deprecations.test.ts | 2 +- src/core/server/config/deprecation/core_deprecations.ts | 7 +++++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/cli/serve/serve.js b/src/cli/serve/serve.js index fb24fa2cf262f..13c16691bf12a 100644 --- a/src/cli/serve/serve.js +++ b/src/cli/serve/serve.js @@ -116,11 +116,11 @@ function applyConfigOverrides(rawConfig, opts, extraCliOptions) { set('logging.root.level', 'off'); } if (opts.verbose) { - // Only set logging.verbose to true when KP logging isn't configured. - if (!has('rawConfig.logging.root.appenders')) { - set('logging.verbose', true); - } else { + if (has('logging.root.appenders')) { set('logging.root.level', 'all'); + } else { + // Only set logging.verbose to true for legacy logging when KP logging isn't configured. + set('logging.verbose', true); } } diff --git a/src/core/server/config/deprecation/core_deprecations.test.ts b/src/core/server/config/deprecation/core_deprecations.test.ts index be8ad736d42dd..b6b3ab5b8face 100644 --- a/src/core/server/config/deprecation/core_deprecations.test.ts +++ b/src/core/server/config/deprecation/core_deprecations.test.ts @@ -420,7 +420,7 @@ describe('core deprecations', () => { }); expect(messages).toMatchInlineSnapshot(` Array [ - "\\"logging.events.log\\" has been deprecated and will be removed in 8.0. Moving forward, you can use \\"logging.root.level\\" in your logging configuration. ", + "\\"logging.events.log\\" has been deprecated and will be removed in 8.0. Moving forward, log levels can be customized on a per-logger basis using the new logging configuration. ", ] `); }); diff --git a/src/core/server/config/deprecation/core_deprecations.ts b/src/core/server/config/deprecation/core_deprecations.ts index 5a0a22afa91cf..565b957b2a8e1 100644 --- a/src/core/server/config/deprecation/core_deprecations.ts +++ b/src/core/server/config/deprecation/core_deprecations.ts @@ -182,6 +182,10 @@ const verboseLoggingDeprecation: ConfigDeprecation = (settings, fromPath, log) = }; const jsonLoggingDeprecation: ConfigDeprecation = (settings, fromPath, log) => { + // We silence the deprecation warning when running in development mode because + // the dev CLI code in src/dev/cli_dev_mode/using_server_process.ts manually + // specifies `--logging.json=false`. Since it's executed in a child process, the + // ` legacyLoggingConfigSchema` returns `true` for the TTY check on `process.stdout.isTTY` if (has(settings, 'logging.json') && settings.env !== 'development') { log( '"logging.json" has been deprecated and will be removed ' + @@ -211,7 +215,7 @@ const logEventsLogDeprecation: ConfigDeprecation = (settings, fromPath, log) => if (has(settings, 'logging.events.log')) { log( '"logging.events.log" has been deprecated and will be removed ' + - 'in 8.0. Moving forward, you can use "logging.root.level" in your logging configuration. ' + 'in 8.0. Moving forward, log levels can be customized on a per-logger basis using the new logging configuration. ' ); } return settings; @@ -229,7 +233,6 @@ const logEventsErrorDeprecation: ConfigDeprecation = (settings, fromPath, log) = const logFilterDeprecation: ConfigDeprecation = (settings, fromPath, log) => { if (has(settings, 'logging.filter')) { - // usage: logging.filter.cookie=none or logging.filter.authorization=none log('"logging.filter" has been deprecated and will be removed ' + 'in 8.0. '); } return settings;