winstonjs/winston · warning
Level "log" not defined: conflicts with the method "log". Us
Error message
Level "log" not defined: conflicts with the method "log". Use a different level name.
What it means
When createLogger / winston.createLogger builds per-level methods on the logger prototype, a custom level literally named 'log' is skipped with this console.warn, because it would collide with the existing logger.log() method. Unlike the other entries this is a warning, not a thrown Error — the level still works via logger.log('log', ...) but no logger.log-level() shorthand is defined (and the method remains the generic log).
Source
Thrown at lib/winston/create-logger.js:57
* the prototype of. This is a V8 optimization that is well know to increase
* performance of prototype functions.
* @param {!Object} options - Options for the created logger.
*/
constructor(options) {
super(options);
}
}
const logger = new DerivedLogger(opts);
//
// Create the log level methods for the derived logger.
//
Object.keys(opts.levels).forEach(function (level) {
debug('Define prototype method for "%s"', level);
if (level === 'log') {
// eslint-disable-next-line no-console
console.warn('Level "log" not defined: conflicts with the method "log". Use a different level name.');
return;
}
//
// Define prototype methods for each log level e.g.:
// logger.log('info', msg) implies these methods are defined:
// - logger.info(msg)
// - logger.isInfoEnabled()
//
// Remark: to support logger.child this **MUST** be a function
// so it'll always be called on the instance instead of a fixed
// place in the prototype chain.
//
DerivedLogger.prototype[level] = function (...args) {
// Prefer any instance scope, but default to "root" logger
const self = this || logger;
// Optimize the hot-path which is the single object.View on GitHub (pinned to ff0b79de85)
Solutions
- Rename the custom level to something that does not collide, e.g. 'verbose' or 'debug', in your levels object.
- Update all call sites logger.log() shorthand accordingly (use logger.verbose(msg) after renaming).
- If the warning is noise from a third-party levels object, filter 'log' out before passing levels to createLogger.
Example fix
// before
winston.createLogger({ levels: { log: 0, info: 1, error: 2 } });
// after
winston.createLogger({ levels: { verbose: 0, info: 1, error: 2 } }); Defensive patterns
Strategy: validation
Validate before calling
const levels = { log: 0, info: 1, error: 2 };
if ('log' in levels) {
console.warn("Renaming reserved custom level 'log'");
const { log, ...rest } = levels;
levels = { verbose: log, ...rest };
}
winston.createLogger({ levels }); Prevention
- Never name a custom level 'log' — it collides with logger.log().
- Lint custom level config against a reserved-word list at startup.
- When merging level sets, dedupe and check for 'log' first.
When it happens
Trigger: winston.createLogger({ levels: { log: 0, info: 1, ... } }) — a custom levels object containing the key 'log'.
Common situations: Custom level schemes copied from configs that include a catch-all 'log' level; merging default npm levels with custom levels and accidentally including 'log'; YAML/JSON-driven level definitions.
Related errors
- { %s } was removed in winston@3.0.0.
- { %s } was removed in winston@3.0.0. Use a custom winston.fo
- Logger is required to handle exceptions
- ExceptionStream requires a TransportStream instance.
- { colors, emitErrs, formatters, padLevels, rewriters, stripC
AI-assisted analysis of winstonjs/winston@ff0b79de85 (2026-08-31).
Data as JSON: /api/errors/a57131d071c4521c.
Report an issue: GitHub.