From 6f38b966440a1e9cb1610d17e0907893c9732956 Mon Sep 17 00:00:00 2001 From: "Christiane (Tina) Heiligers" Date: Wed, 17 Mar 2021 19:15:15 -0700 Subject: [PATCH] [core.logging] Deprecates legacy logging dest, json, verbosity and rotate configurations (#94238) (#94878) Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> # Conflicts: # docs/migration/migrate_8_0.asciidoc # src/core/server/config/deprecation/core_deprecations.ts --- packages/kbn-config/src/env.ts | 5 +- packages/kbn-legacy-logging/src/schema.ts | 9 +- src/cli/serve/serve.js | 25 ++- .../deprecation/core_deprecations.test.ts | 186 ++++++++++++++++-- .../config/deprecation/core_deprecations.ts | 116 ++++++++++- .../config_deprecation.test.ts | 9 +- src/core/server/logging/README.mdx | 21 +- src/core/test_helpers/kbn_server.ts | 1 - src/legacy/server/kbn_server.d.ts | 1 - src/legacy/server/kbn_server.js | 16 +- src/legacy/server/logging/index.js | 6 +- 11 files changed, 333 insertions(+), 62 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..76d7381ee8728 100644 --- a/packages/kbn-legacy-logging/src/schema.ts +++ b/packages/kbn-legacy-logging/src/schema.ts @@ -11,7 +11,12 @@ 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; @@ -38,13 +43,11 @@ export const legacyLoggingConfigSchema = Joi.object() root: HANDLED_IN_KIBANA_PLATFORM, silent: Joi.boolean().default(false), - 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), diff --git a/src/cli/serve/serve.js b/src/cli/serve/serve.js index 891f2b0fff797..13c16691bf12a 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; } @@ -112,10 +111,18 @@ 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.silent) { + set('logging.silent', true); + set('logging.root.level', 'off'); + } + if (opts.verbose) { + 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); + } + } set('plugins.scanDirs', _.compact([].concat(get('plugins.scanDirs'), opts.pluginDir))); set('plugins.paths', _.compact([].concat(get('plugins.paths'), opts.pluginPath))); @@ -140,11 +147,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,6 +214,7 @@ export default function (program) { cliArgs: { dev: !!opts.dev, envName: unknownOptions.env ? unknownOptions.env.name : undefined, + // no longer supported quiet: !!opts.quiet, silent: !!opts.silent, watch: !!opts.watch, diff --git a/src/core/server/config/deprecation/core_deprecations.test.ts b/src/core/server/config/deprecation/core_deprecations.test.ts index 5bb2ebf702aa7..c63ebb6c9c551 100644 --- a/src/core/server/config/deprecation/core_deprecations.test.ts +++ b/src/core/server/config/deprecation/core_deprecations.test.ts @@ -264,17 +264,10 @@ 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", ] `); }); - - 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', () => { @@ -284,7 +277,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", ] `); }); @@ -295,7 +288,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,36 +299,187 @@ 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", ] `); }); + }); - it('does not warn when other events are configured', () => { + describe('logging.timezone', () => { + it('warns when ops events are used', () => { const { messages } = applyCoreDeprecations({ - logging: { events: { log: '*' } }, + logging: { timezone: 'GMT' }, }); - expect(messages).toEqual([]); + 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.mdx", + ] + `); }); }); - describe('logging.timezone', () => { - it('warns when ops events are used', () => { + describe('logging.dest', () => { + it('warns when dest is used', () => { const { messages } = applyCoreDeprecations({ - logging: { timezone: 'GMT' }, + 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.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", + ] + `); + }); + 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.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx.", + ] + `); + }); + }); + + 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. Moving forward, you can use \\"logging.root.level:error\\" in your logging configuration. ", + ] + `); + }); + 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. Moving forward, you can use \\"logging.root.level:off\\" in your logging configuration. ", + ] + `); + }); + 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. Moving forward, you can use \\"logging.root.level:all\\" in your logging configuration. ", + ] + `); + }); + }); + + 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 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.", + ] + `); + }); + }); + + 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 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", + ] + `); + }); + + 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 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", + ] + `); + }); + + it('warns when logging.rotate.everyBytes configurations are used', () => { + const { messages } = applyCoreDeprecations({ + logging: { rotate: { enabled: true, everyBytes: 1048576 } }, }); 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.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", ] `); }); - it('does not warn when other events are configured', () => { + it('warns when logging.rotate.keepFiles is used', () => { const { messages } = applyCoreDeprecations({ - logging: { events: { log: '*' } }, + logging: { rotate: { enabled: true, keepFiles: 1024 } }, }); - expect(messages).toEqual([]); + expect(messages).toMatchInlineSnapshot(` + Array [ + "\\"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", + ] + `); + }); + }); + + 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, log levels can be customized on a per-logger basis using the new 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. ", + ] + `); + }); + }); + + 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 966dbaf282c46..461bcf5e6b1d5 100644 --- a/src/core/server/config/deprecation/core_deprecations.ts +++ b/src/core/server/config/deprecation/core_deprecations.ts @@ -119,7 +119,7 @@ const opsLoggingEventDeprecation: ConfigDeprecation = (settings, fromPath, 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; @@ -131,22 +131,123 @@ 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; }; + const timezoneLoggingDeprecation: ConfigDeprecation = (settings, fromPath, log) => { if (has(settings, 'logging.timezone')) { 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; +}; + +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.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx.' + ); + } + return settings; +}; + +const quietLoggingDeprecation: ConfigDeprecation = (settings, fromPath, log) => { + if (has(settings, 'logging.quiet')) { + log( + '"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; }; + +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 ' + + '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.' + ); + } + return settings; +}; + +const logRotateDeprecation: ConfigDeprecation = (settings, fromPath, log) => { + 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 ' + + 'in your logging configuration. For more details, see ' + + 'https://github.com/elastic/kibana/blob/master/src/core/server/logging/README.mdx#rolling-file-appender' + ); + } + 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, log levels can be customized on a per-logger basis using the new 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; +}; + +const logFilterDeprecation: ConfigDeprecation = (settings, fromPath, log) => { + if (has(settings, 'logging.filter')) { + log('"logging.filter" has been deprecated and will be removed ' + 'in 8.0. '); + } + return settings; +}; + export const coreDeprecationProvider: ConfigDeprecationProvider = ({ unusedFromRoot, renameFromRoot, @@ -196,4 +297,13 @@ export const coreDeprecationProvider: ConfigDeprecationProvider = ({ opsLoggingEventDeprecation, requestLoggingEventDeprecation, timezoneLoggingDeprecation, + destLoggingDeprecation, + quietLoggingDeprecation, + silentLoggingDeprecation, + verboseLoggingDeprecation, + jsonLoggingDeprecation, + logRotateDeprecation, + logEventsLogDeprecation, + logEventsErrorDeprecation, + logFilterDeprecation, ]; 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..5b672774c515a 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.silent\\" has been deprecated and will be removed in 8.0. Moving forward, you can use \\"logging.root.level:off\\" in your logging configuration. ", + ] + `); }); 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.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/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| diff --git a/src/core/test_helpers/kbn_server.ts b/src/core/test_helpers/kbn_server.ts index 14f614643ac9f..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/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/kbn_server.js b/src/legacy/server/kbn_server.js index d2eebb7b0cd23..4bc76b6a7706f 100644 --- a/src/legacy/server/kbn_server.js +++ b/src/legacy/server/kbn_server.js @@ -94,20 +94,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; } @@ -133,13 +126,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..1b2ae59f4aa00 100644 --- a/src/legacy/server/logging/index.js +++ b/src/legacy/server/logging/index.js @@ -6,13 +6,9 @@ * 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)); - }); - const loggingConfig = config.get('logging'); const opsInterval = config.get('ops.interval');