winstonjs/winston · error · Error

{ colors, emitErrs, formatters, padLevels, rewriters, stripC

Error message

{ colors, emitErrs, formatters, padLevels, rewriters, stripColors } were removed in winston@3.0.0.
Use a custom winston.format(function) instead.
See: https://github.com/winstonjs/winston/tree/master/UPGRADE-3.0.md

What it means

In winston 3, `logger.configure(options)` rejects the removed winston 2.x options — `colors`, `emitErrs`, `formatters`, `padLevels`, `rewriters`, `stripColors`. This also fires via the Logger constructor, which delegates to configure. The rewrite moved all message shaping into the `winston.format` pipeline, so these legacy options are treated as a hard configuration error with a pointer to the upgrade guide.

Source

Thrown at lib/winston/logger.js:137

    this.rejections = new RejectionHandler(this);
    this.profilers = {};
    this.exitOnError = exitOnError;

    // Add all transports we have been provided.
    if (transports) {
      transports = Array.isArray(transports) ? transports : [transports];
      transports.forEach(transport => this.add(transport));
    }

    if (
      colors ||
      emitErrs ||
      formatters ||
      padLevels ||
      rewriters ||
      stripColors
    ) {
      throw new Error(
        [
          '{ colors, emitErrs, formatters, padLevels, rewriters, stripColors } were removed in winston@3.0.0.',
          'Use a custom winston.format(function) instead.',
          'See: https://github.com/winstonjs/winston/tree/master/UPGRADE-3.0.md'
        ].join('\n')
      );
    }

    if (exceptionHandlers) {
      this.exceptions.handle(exceptionHandlers);
    }
    if (rejectionHandlers) {
      this.rejections.handle(rejectionHandlers);
    }
  }

  /**
   * Helper method to get the highest logging level associated with a logger

View on GitHub (pinned to ff0b79de85)

Solutions

  1. Delete the removed options from the config object.
  2. Move level/`colors` customization to `winston.addColors(colors)` and level sets via the `levels` option.
  3. Replace formatters/rewriters/stripColors/padLevels with `winston.format.combine(...)` including `format.colorize()`, `format.padLevels()`, `format.printf()`, or a custom `winston.format(fn)`.
  4. Remove `emitErrs` and handle transport errors via the logger/transport `error` event instead.
  5. Follow UPGRADE-3.0.md for a per-option mapping.

Example fix

// before (winston 2.x)
const logger = new winston.Logger({
  colors: { info: 'blue' },
  padLevels: true,
  rewriters: [(level, msg, meta) => meta]
});

// after (winston 3.x)
winston.addColors({ info: 'blue' });
const logger = winston.createLogger({
  format: winston.format.combine(
    winston.format.colorize(),
    winston.format.padLevels()
  ),
  transports: [new winston.transports.Console()]
});
Defensive patterns

Strategy: validation

Validate before calling

const REMOVED = ['colors', 'emitErrs', 'formatters', 'padLevels', 'rewriters', 'stripColors'];
const bad = REMOVED.filter(k => k in loggerOptions);
if (bad.length) throw new TypeError(`Removed winston 2.x options: ${bad.join(', ')} — migrate to winston.format`);

Try / catch

try {
  logger.configure(opts);
} catch (err) {
  if (err.message.includes('were removed in winston@3.0.0')) {
    const { colors, ...rest } = opts;
    if (colors) winston.addColors(colors);
    logger.configure(rest);
  } else { throw err; }
}

Prevention

When it happens

Trigger: Passing any of `{ colors, emitErrs, formatters, padLevels, rewriters, stripColors }` in the options object to `new winston.Logger({...})` or `logger.configure({...})` — e.g. `new winston.Logger({ colors: {...} })` or `configure({ rewriters: [...] })`.

Common situations: Direct winston 2.x -> 3.x migration where the old logger options object is reused; config files loaded from JSON containing v2 option names; frameworks or wrappers that still emit v2-style logger options.

Related errors


AI-assisted analysis of winstonjs/winston@ff0b79de85 (2026-08-31). Data as JSON: /api/errors/8ce62ec89890ed49. Report an issue: GitHub.