iotex-core icon indicating copy to clipboard operation
iotex-core copied to clipboard

Better Management of Log Files

Open dustinxie opened this issue 3 years ago • 12 comments

Why is this needed: The current log file is monolithic and keeps growing in size, and becomes too large to be managed.

What would you like to be added:

  1. have a separate log file every day, e.g., 1011.log, 1012.log, 1013.log...
  2. log rotation - only keep the recent 30days of logs
  3. make both features configurable

For all these features, you can refer to how Nginx manages logs.

Compatibility don't break the current ELK pipeline make sure the log ingestion in ELK still works (cc @xianhuawei )

dustinxie avatar May 10 '21 18:05 dustinxie

@millken you may refer to https://programmer.help/blogs/zap-log-classification-and-file-splitting-log-cutting-by-time-integration-demo.html using some existing tools

CoderZhi avatar Oct 14 '21 05:10 CoderZhi

@millken you may refer to https://programmer.help/blogs/zap-log-classification-and-file-splitting-log-cutting-by-time-integration-demo.html using some existing tools

https://github.com/lestrrat-go/file-rotatelogs

WARNINGS THIS PROJECT HAS BEEN ARCHIVED. IT WILL NOT RECEIVE UPDATES, THE AUTHOR DOES NOT WISH TO MAINTAIN OR SUPPORT IT. IN SHORT, DO NOT USE THIS PROJECT.

millken avatar Oct 18 '21 02:10 millken

@millken you may refer to https://programmer.help/blogs/zap-log-classification-and-file-splitting-log-cutting-by-time-integration-demo.html using some existing tools

https://github.com/uber-go/zap/blob/master/FAQ.md#usage Built-in log management is hard to maintain. We could use mature tools, like logrotate or lumberjack

Liuhaai avatar Oct 28 '21 20:10 Liuhaai

lumberjack rolling files focusd on maxSize, not by timeFormat, RotateFile also refers to its code.

millken avatar Oct 30 '21 04:10 millken

lumberjack rolling files focusd on maxSize, not by timeFormat, RotateFile also refers to its code.

lumberjack can automatically roll log files based either on date or on file size..

Liuhaai avatar Nov 01 '21 04:11 Liuhaai

Pls see code first https://github.com/natefinch/lumberjack/blob/7d6a1875575e09256dc552b4c0e450dcd02bd10e/lumberjack.go#L152-L156

lumberjack rolling files focusd on maxSize, not by timeFormat, RotateFile also refers to its code.

lumberjack can automatically roll log files based either on date or on file size..

millken avatar Nov 02 '21 09:11 millken

Pls see code first https://github.com/natefinch/lumberjack/blob/7d6a1875575e09256dc552b4c0e450dcd02bd10e/lumberjack.go#L152-L156

lumberjack rolling files focusd on maxSize, not by timeFormat, RotateFile also refers to its code.

lumberjack can automatically roll log files based either on date or on file size..

thx for the info. Logrotate might be a better alternative.

Liuhaai avatar Nov 02 '21 17:11 Liuhaai

Pls see code first https://github.com/natefinch/lumberjack/blob/7d6a1875575e09256dc552b4c0e450dcd02bd10e/lumberjack.go#L152-L156

lumberjack rolling files focusd on maxSize, not by timeFormat, RotateFile also refers to its code.

lumberjack can automatically roll log files based either on date or on file size..

thx for the info. Logrotate might be a better alternative.

@xianhuawei - can this be realized at k8s level using Logrotate ?

raullenchai avatar Nov 08 '21 05:11 raullenchai

Pls see code first https://github.com/natefinch/lumberjack/blob/7d6a1875575e09256dc552b4c0e450dcd02bd10e/lumberjack.go#L152-L156

lumberjack rolling files focusd on maxSize, not by timeFormat, RotateFile also refers to its code.

lumberjack can automatically roll log files based either on date or on file size..

thx for the info. Logrotate might be a better alternative.

@xianhuawei - can this be realized at k8s level using Logrotate ?

Here is an article introduces log-roration tools on kubernetes logging. @xianhuawei Could you give a try?

Liuhaai avatar Nov 18 '21 21:11 Liuhaai

This is what happened on a node

sgp1-01:~/iotex-var/log# ls
s.log  update.log
sgp1-01:~/iotex-var/log# du -sh .
8.9G	.

raullenchai avatar Jan 04 '22 17:01 raullenchai

As of now, this problem still exists. Reopen the issue

###:~/iotex-var/log# du -sh .
8.6G	.

raullenchai avatar Sep 07 '22 00:09 raullenchai

As of now, this problem still exists. Reopen the issue

###:~/iotex-var/log# du -sh .
8.6G	.

This is for a node that is NOT running k8s.

raullenchai avatar Sep 07 '22 02:09 raullenchai