iccicci / rotating-file-stream

Opens a stream.Writable to a file rotated by interval and/or size. A logrotate alternative.
MIT License
286 stars 39 forks source link

Asking for advice for "TIMEZONE"s #59

Closed dubiao closed 3 years ago

dubiao commented 4 years ago

Hi I'm trying to rotate my logs by 1day. But it seems that it not good at different timezones.

e.g. I am in Beijing which located at East 8 (+8:00) zone. I set my time zone by:

process.env.TZ = 'Asia/Beijing'

and rotate logs by:

var access200LogStream = rfs('access200.log', {
  interval: '1d', // rotate daily
  path: path.join(__dirname, 'logs')
})

It seems that it cut the logs according the +0:00 timezone.

when I want to see my logs of 2020-08-06 of Beijing timezone, I have to look into the file of 20200805-0000-01-access200.log and grep out the logs later than 05/Aug/2020:16:00:00 +0000

than look into the file named 20200806-0000-01-access200.log and grep out the logs before than 06/Aug/2020:16:00:00 +0000

that is my logs of Beijing day 2020-08-06.

Did I miss some important statements in my code the declare the timezone?

iccicci commented 4 years ago

Hi @dubiao ,

it should be enough... Could you please check that the process.env.TZ = 'Asia/Beijing' setting doesn't change while your app is running, for any other reason?

Thank you, iCC

iccicci commented 3 years ago

Closing for lack of feedback