diff --git a/lib/winston/logger.js b/lib/winston/logger.js index 5f8758c89..61a9fcb0f 100644 --- a/lib/winston/logger.js +++ b/lib/winston/logger.js @@ -141,6 +141,17 @@ class Logger extends Transform { ); } + if (!Object.keys(this.levels).includes(this.level)) { + const message = [ + '[winston] Log level <${this.level}> is not defined in levels definition.', + 'Please double check the setup of your transports and/or custom log levels.', + 'This transport will be set to silent.', + 'See https://github.com/winstonjs/winston#logging-levels for more information.' + ].join('\n'); + console.warn(message); + this.silent = true; + } + if (exceptionHandlers) { this.exceptions.handle(exceptionHandlers); }