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.

Keep same file name for log and rotate the file with timestamp

See original GitHub issue

logger.txt

I’m using winston@3.3.3 and winston-daily-rotate-file@4.5.0 In my logger configuration I have the following.

var transportError = new (winston.transports.DailyRotateFile)({
  filename: HOME_DIR + '/logs/backend/error/error-%DATE%.log',
  datePattern: 'YYYY-MM-DD-HH',
  zippedArchive: false,
  maxSize: '50m',
  maxFiles: '14d',
  level: 'error',
  name: 'error',

  createSymlink: true,
  symlinkName: 'error.log',
  tailable: true,

  handleExceptions: true,
  json: true,
  colorize: false,
});

this is supposed to be like current log file should be error.log and when rotates it should get append with date format

even though I have mentioned createSymlink, tailable set to true symlinkName with ‘error.log’ my current log files are like this error-2021-02-01-13.log, error-2021-02-01-12.log

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
mohsenmahoskicommented, Oct 10, 2021

I don’t understand the symlink options. Why not have the current file without any date/number and just apply them after a rotation? That’s what I need and what I had used in other languages. IMHO the mentioned options over-complicate the usage.

I don’t want to config my elastic search to watch the file with pattern. I thing its very important to have the current file without any pattern

2reactions
jalbierocommented, Apr 16, 2021

I don’t understand the symlink options. Why not have the current file without any date/number and just apply them after a rotation? That’s what I need and what I had used in other languages. IMHO the mentioned options over-complicate the usage.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rotate log files with timestamp in file name - Server Fault
If you're already creating the files with the date in the name, logrotate isn't the answer; it is based around the idea of...
Read more >
Logrotate files with date in the file name - Stack Overflow
Logrotate will only perform the operations it has been configured to perform. If you specify a daily rotate, it will not rotate again...
Read more >
How to Manage Log Files Using Logrotate - Datadog
Log rotation, which is managed by tools like logrotate, solves these problems by performing routine maintenance on log files. Rotation refers to ...
Read more >
Timestamp based target log file name configuration in logrotate
Description of problem: According to the "logrotate" manual page there do exist the following directives to influence the file name of the rotated...
Read more >
Rotate Log Files — MongoDB Manual
Rotating log files does not modify the "old" rotated log files. When you rotate a log, you rename the server1.log file to include...
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