question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Filename not being followed - filename always has date appended

See original GitHub issue

When I set the file name transport as follows (or without the datePattern option):

  transport = new (winston.transports.DailyRotateFile)({
    filename: "applicaton.log",
    datePattern: '',
    zippedArchive: true,
    maxSize: '20m',
    maxFiles: '14d'
  });

It appends the current date and creates a file with the name “application.log.2021-03-24”. I need the name to be exactly as specified, without a date. The rolled file name isn’t a concern. How can I achieve this?

Thank you

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
mdottavicommented, Sep 22, 2021

@mattberther Does symlinkName option works correctly even if dirname option is added? I use next options with winstonDailyRotateFile and as a result it creates winston.log.2021-05-07 file instead of info.log that I expect?

const createLogger: Function = 
    (filename: string): winston.Logger => winston.createLogger({
        level: 'info',
        format: formatter,
        transports: [new winstonDailyRotateFile({
            dirname: logsFolder,
            createSymlink: true,
            symlinkName: 'info.log',
            maxFiles: '7d'
        })]
    });

Were you able to solve the issue? I am also stuck on this issue

I did the following, and it worked for me.

`

new transports.DailyRotateFile({
        level: 'warn',
        filename: './logs/error.%DATE%.log',
        auditFile: './logs/audits/error.audit.json',
        dirname: './logs',
        createSymlink: true,
        symlinkName: 'error.log',
        handleExceptions: true,
        json: false,
        maxSize: '20m',
        maxFiles: '7d',
        datePattern: 'YYYY-MM-DD',
        colorize: false,
        format: combine(
            format.colorize(),
            splat(),
            timestamp({ format: 'YYYY-MM-DD HH:mm:ss.SSS' }),
            myFormat
          ),    
    }),

` The result was in logs directory: error.2021-09-22.log* error.log -> error.2021-09-22.log*

1reaction
nikita-lipnyagovcommented, May 7, 2021

@mattberther Does symlinkName option works correctly even if dirname option is added?

I use next options with winstonDailyRotateFile and as a result it creates winston.log.2021-05-07 file instead of info.log that I expect?

const createLogger: Function = 
    (filename: string): winston.Logger => winston.createLogger({
        level: 'info',
        format: formatter,
        transports: [new winstonDailyRotateFile({
            dirname: logsFolder,
            createSymlink: true,
            symlinkName: 'info.log',
            maxFiles: '7d'
        })]
    });
Read more comments on GitHub >

github_iconTop Results From Across the Web

Solved: Flow to automatically append date to filename in s...
In your implementation, when building the new file name; original file name is stored first, then you add a '_' symbol, then current...
Read more >
Why is the date appended twice on filenames when using ...
Append the date to the file name again. 4. Successfully access the file (which has the weird file name now).
Read more >
bash - Appending a current date from a variable to a filename
You also do not want to use & at the end of your statements; which causes the shell to not wait for the...
Read more >
How To Append Current Date To Filename in Bash Shell
There should not be a whitespace between + and the format string on line 3. Change $(date + “%Y-%m-%d”) to $(date +”%Y-%m-%d”).
Read more >
How to Save a File Name With the Date
Rename the file including the date. Use dashes to separate portions of the name: the Windows operating system excludes certain characters from file...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found