15

I'm using Winston logging and have specified file size to be max 10MB.

{
    filename: 'e:\app.log', 
    json:false, 
    maxsize:'10MB', 
    maxFiles:'10', 
    timestamp:true, 
    level:'silly'
}

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 even GBs.

Is there something I'm doing wrongly? Thanks.

Lee
  • 2,874
  • 3
  • 27
  • 51
  • looks like you might need to either pass an absolute path for the `filename` or set a `dirname` according to this somewhat old [github issue](https://github.com/flatiron/winston/issues/90). – go-oleg Jul 30 '14 at 06:00
  • Go-oleg, thanks. In fact, in my code, it is absolute path. Re-updated my question. – Lee Jul 30 '14 at 06:02
  • 3
    I believe the value for `maxsize` should be in bytes, so you could try `10000000` instead of `'10MB'`. – go-oleg Jul 30 '14 at 06:04

3 Answers3

23

As you can see here the maxsize must be in bytes so change it for 10000000

Dushyant Bangal
  • 6,048
  • 8
  • 48
  • 80
Victor Castillo Torres
  • 10,581
  • 7
  • 40
  • 50
0

Use maxSize instead of maxsize it will work.

Varun verma
  • 189
  • 4
  • 19
0

I think maxSize applies only for the file.

But before write inside it the Log Entry Size could be greater than the limit.

My question is if there are something similar like maxEntrySize to limit the log entry size directly, not only file size.

Luis Roberto
  • 375
  • 4
  • 10