Skip to content

maxFiles: keeps only the latest modified files in a folder (multiple transports to same folder) #181

Closed
@wolfcode

Description

@wolfcode

environment:

  • winston: "^3.1.0"
  • _node -v: v10.8.0
  • Operating System? macOS
  • Language? TypeScript 2.6

What is the problem?

creating winston logger with multiple transporters into the same directory.
Now, setting maxFiles to 4 will keep only 4 files of latest updated in the folder.

What do you expect to happen instead?

I expect to keep 4 maxFiles of serverLog and also 4 maxFiles of errorLog.

Other information

I'm using this function to create transport options.

const createTransportOpts = (fileName, level) => ({
  filename: `${fileName}-%DATE%.log`,
  datePattern: 'DD-MM-YYYY',
  maxSize: '10m',
  level,
  maxFiles: 4,
`});

Creating logger with multiple transports,

const logger = createLogger({
  level: 'info',
  format: combine(
    DateTimeFormat,
    myFormat,
  ),
  transports: [
    new (transports.DailyRotateFile)(
      createTransportOpts(path.join('/logs/', 'error'), 'error'),
    ),
    new (transports.DailyRotateFile)(
      createTransportOpts(path.join('/logs/', 'server')),
    ),
  ],
});

Activity

mattberther

mattberther commented on Oct 25, 2018

@mattberther
Member

Updated to file-stream-rotator@0.4.0 and published winston-daily-rotate-file@3.3.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @mattberther@wolfcode

        Issue actions

          maxFiles: keeps only the latest modified files in a folder (multiple transports to same folder) · Issue #181 · winstonjs/winston-daily-rotate-file