winstonjs / winston-daily-rotate-file

A transport for winston which logs to a rotating file each day.
MIT License
889 stars 151 forks source link

Symlink not created on windows10 #365

Open danielj13LR opened 1 year ago

danielj13LR commented 1 year ago

this is my transport configuration, it works on windows 11, linux, mac etc but for some reason not on windows 10.

{
      dirname: os.tempdir(),
      filename: 'myLogFile',
      datePattern: 'YYYY-MM-DD-HH',
      createSymlink: true,
      symlinkName: 'myLogFile',
      maxSize: '2k',
      maxFiles: '5',
    }

im only getting the file with date (meaning 'myLogFile2023-01-01-16-02') tried to add extension but it didn't help. I'm using version 4.7.1. I tried finding some issues that discuss this problem but found non from this version. also tried this demo from stackoverflow which didnt work.

var os = require('os');
var winston = require('winston');
require('winston-daily-rotate-file');

var transport = new winston.transports.DailyRotateFile({
    dirname: os.tmpdir(),
    frequency: '1m',
    filename: 'log',
    datePattern: 'YYYY-MM-DD-HH-mm',
    zippedArchive: false,
    maxSize: '1k',
    maxFiles: '2',
    extension: '.log'

});

var logger = winston.createLogger({
    transports: [
        transport
    ]
});

async function demo() {
    for (i = 1; i < 20; i++) {
        logger.info('Hello World ' + i);
        console.log(i);
        await new Promise(r => setTimeout(r, 10000));
    }
}

demo();

any suggestions ? is it a known bug?

kafeijao commented 1 year ago

I have the same issue, but on windows 10 and 4.7.1 npm: 8.19.3 node: v18.13.0

Also tested with all older versions until the 4.0.0 and also did not work.

guatemartin commented 6 months ago

I have the same issue, but it's running on windows server 2019. Ver is 4.7.1

Efferbach commented 4 months ago

I experienced the same issue on Windows 11 Pro. winston-daily-rotatte-file: 5.0.0 winston: 3.13.0 npm: 10.2.4 node: v20.11.0 {

  filename: 'logs/debug/%DATE%-debug.log',
  level: 'debug',
  datePattern: 'YYYY-MM-DD',
  maxFiles: '30d',
  zippedArchive: true,
  createSymlink: true,
  symlinkName: 'debug.log'

}

When I run it as admin it works and the symbolic link is created and can be used as intended.

If I run without admin privileges I can't create the symbolic link. When I run it without admin privileges after I have created the symbolic link as admin, the link is deleted.