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.

File Transport maxsize is not working as expect

See original GitHub issue

Hi All,

I find that when I define the file transport with setting as followed

const logger = new (winston.Logger)({
    transports: [
        new (winston.transports.File)({
            filename: config['log_file_name'],
            dirname: '/data/tmp/',
            //maxsize: 1000 * 1000 * 1024, // 1Gb
            maxsize: 102400, // 100 kb
            maxFiles: 1000,
            timestamp: function() {
                return Date.now()/1000|0;
            }
        })
    ],
    exitOnError: false
})

then, the final log size will be 4 times than the maxsize.

404K    rcv.log
400K    rcv1.log
240K    rcv2.log

According to the documentation, this result is not expected.

Thanks

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:2
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
apsavincommented, Apr 10, 2016

I use the following code for transport initialization:

winston.add(winston.transports.File, {
  name: 'errors',
  filename: 'logs/errors.log',
  level: 'error',
  maxsize: 10,
});

And then:

server.listen(server.get('port'), () => {
  winston.info(`The server is running at http://localhost:${server.get('port')}/`);
  winston.error(new Error('asdsad'));
  winston.error('cvxcvxcvcxvxcvxcvxcvxc');
  winston.error('cvxcvxcvcxvxcvxcvxcvxc');
  winston.error('cvxcvxcvcxvxcvxcvxcvxc');
  winston.error('cvxcvxcvcxvxcvxcvxcvxc');
  winston.error('cvxcvxcvcxvxcvxcvxcvxc');
  winston.error('cvxcvxcvcxvxcvxcvxcvxc');
  winston.error('cvxcvxcvcxvxcvxcvxcvxc');
  winston.error('cvxcvxcvcxvxcvxcvxcvxc');
  winston.error('cvxcvxcvcxvxcvxcvxcvxc');
  winston.error('cvxcvxcvcxvxcvxcvxcvxc');
  winston.error('cvxcvxcvcxvxcvxcvxcvxc');
  winston.error('cvxcvxcvcxvxcvxcvxcvxc');
  winston.error('cvxcvxcvcxvxcvxcvxcvxc');
  winston.error('cvxcvxcvcxvxcvxcvxcvxc');
});

##Expected result:

several files, each file as small as possible.

##Actual result:

one big file with all messages

1reaction
anamdevcommented, Feb 4, 2016

I am facing same issue winston 2.2.1. It is also writing in last 2-3 rotated log files. Is there any fix for it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

NodeJS winston log file not change upon size limit
I'm expecting the app.log file to be rotated upon size reaching 10MB, but this has never happened and my log file grows to...
Read more >
Local File logging driver - Docker Documentation
The local logging driver uses file-based storage. The file-format and ... The following example sets the log driver to local and sets the...
Read more >
Node.js Logging with Winston - Reflectoring
In large applications, recording every log message into a single file is not a good idea. This makes tracking specific issues difficult. Using ......
Read more >
Troubleshooting Client VPN - AWS Documentation
Unable to resolve Client VPN endpoint DNS name; Traffic is not being split ... Authorization rules for Active Directory groups not working as...
Read more >
Chapter 23. Viewing and Managing Log Files
Using the Log Files to Troubleshoot Problems ... Mail Transport Protocols ... Output channels are primarily used to specify the maximum size a...
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