rogerc / file-stream-rotator

NodeJS file stream rotator
MIT License
143 stars 69 forks source link

Enable logfiles without date string appended #80

Closed drmarkfernie closed 2 years ago

drmarkfernie commented 3 years ago

The motivation for these changes is to ensure that logs are in order, even if the clock time changes. This means we cannot have the date string in the logfile name, and we must pick the last log file at startup.

rogerc commented 2 years ago

@drmarkfernie Thanks for the PR.

I've tried using the current settings and you can achieve what I believe you want using the current code without requiring changes.

The settings below will add the rotation number in between the file name and the extension.

var rotatingLogStream = require('../FileStreamRotator').getStream({
    filename:"logs/nodate/%DATE%", 
    frequency:"custom", 
    verbose: true, 
    date_format: "[LOGFILENAME]", 
    size:"50k",
    max_logs: "5", 
    audit_file:"audit-nodate.json",
    end_stream: false,
    extension: ".log"
});

If you want the rotation at the end, you can use the config below.

var rotatingLogStream = require('../FileStreamRotator').getStream({
    filename:"logs/nodate/%DATE%", 
    frequency:"custom", 
    verbose: true, 
    date_format: "[LOGFILENAME.EXT]", 
    size:"50k",
    max_logs: "5", 
    audit_file:"audit-nodate.json",
    end_stream: false,
});

I'll close the PR for now. If what I suggest doesn't achieve what you need please reopen the PR. Thanks.