Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

option to enable build-in log rotation enabled leveraging glog #5688

Open
wey-gu opened this issue Aug 22, 2023 · 2 comments
Open

option to enable build-in log rotation enabled leveraging glog #5688

wey-gu opened this issue Aug 22, 2023 · 2 comments
Labels
good first issue Community: perfect as the first pull request hacktoberfest hacktoberfest events help wanted Community: does anyone want to work on it? type/feature req Type: feature request

Comments

@wey-gu
Copy link
Contributor

wey-gu commented Aug 22, 2023

ref: https://discuss.nebula-graph.com.cn/t/topic/13787/9?u=wey

cc @yixinglu

@wey-gu wey-gu added the type/feature req Type: feature request label Aug 22, 2023
@wey-gu wey-gu changed the title option to enable build-in log rotation enabled by glog option to enable build-in log rotation enabled leveraging glog Aug 22, 2023
@wey-gu wey-gu added help wanted Community: does anyone want to work on it? good first issue Community: perfect as the first pull request labels Aug 22, 2023
@wey-gu wey-gu added the hacktoberfest hacktoberfest events label Sep 26, 2023
@jyf111
Copy link

jyf111 commented Oct 18, 2023

As discussed in the forum, glog provides --max_log_size=x option. When the log file size exceeds x MB, glog will create and write to a new file, but the old file is never automatically deleted.

Besides, when setting --timestamp_in_logfile_name=false, --max_log_size no longer works. Because without the timestamp, the new file name is the same as the old file, and glog sets the append attribute.

To automatically delete over-sized old files, glog provides google::EnableLogCleaner(overdue_days). It scans the log dir and removes files with names matching <program name>.<hostname>.<user name>.log.<severity level> (to avoid mistaken deletion) and that have not been modified for over overdue_days, whenever a flush is performed. To avoid frequent scans, glog v0.6 also provides --logcleansecs=x option, then it scans again only after x secs.

So, I think we can add a logcleandays option, and just add the following code to src/daemons/SetupLogging.cpp.

if (FLAGS_logcleandays > 0) {
  google::EnableLogCleaner(FLAGS_logcleandays);
}

We may also add max_log_size=1800, log_clean_days=0 and stop_logging_if_full_disk=false to *.conf.default.

Then, edit max_log_size=x, log_clean_days=y, stop_logging_if_full_disk=true (optional) in *.conf to enable (approximate) log roration.

@Aanchallllll
Copy link

Hello,
would like to contribute.can i be assigned?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Community: perfect as the first pull request hacktoberfest hacktoberfest events help wanted Community: does anyone want to work on it? type/feature req Type: feature request
Projects
Development

No branches or pull requests

3 participants