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

Add support for deleting old logs #36

Closed
isaoa opened this issue Jun 22, 2015 · 21 comments
Closed

Add support for deleting old logs #36

isaoa opened this issue Jun 22, 2015 · 21 comments

Comments

@isaoa
Copy link

isaoa commented Jun 22, 2015

Hi,
Can we add a support for deleting old logs?
As of now, log just keeps accumulating until it takes entire disk space.
If we set the max log size to 10MB, glog keeps generating 10MB log files never deleting.
I'd like to keep only latest 4 logs (of 10MB or smaller).

I know there are tools which can be run to do the cleanup such as logrotate.
We make Windows DLL which runs on embedded machine made by another company. We don't have control on this embedded machine, so we cannot run any program to rotate the log.

I've added RotateLogFile function which checks for number of log files and deletes old logs.
RotateLogFile is run in LogFileObject::Write as it log is rolled over and new log file is created (when max_log_size is reached).

so if we have following 4 logs,

log_20150617-141944.8600
log_20150618-166949.8600
log_20150619-119953.8600
log_20150620-107957.8600

And if a new one is created, the oldest one is deleted leaving 4 logs
log_20150617-141944.8600 <-Deleted
log_20150618-163949.8600
log_20150619-112953.8600
log_20150620-101957.8600
log_20150621-103957.8600 <-- Created

Has this feature been considered before? Can you add this?

Thanks,

Isao

@bitkevin
Copy link

I have the same problem, can't use linux logrotate to delete old log files.

@ezegomez
Copy link
Contributor

ezegomez commented Sep 7, 2016

See also #19 for a possible solution that enables logrotate support (I still need to update it to the latest master though)

@isaoa
Copy link
Author

isaoa commented Sep 7, 2016

Hi ezegomez,
Thanks for the suggestions.

I'm not sure the suggested change would solve my problem.
If I understand correctly, your change would append to existing log after restart.
We need to keep ability to limit the total size of the log, let's say to 10MB.

  1. start program. it sets max_log_size to 10MB.
  2. program writes to myapp.log.
  3. program restarts
  4. program appends to myapp.log
    what would happen once it reaches the size limit of 10MB?

would it keep writing past 10MB or delete myapp.log and recreates the same file?

Either way, it won't work for us, as we want to limit the amount of logs and at the same time don't want to lose all logs when log rotates.

@sudhi-vm

This comment has been minimized.

1 similar comment
@hanzeil

This comment has been minimized.

@njpillitteri

This comment has been minimized.

2 similar comments
@WangAndrew2016

This comment has been minimized.

@asierguti

This comment has been minimized.

@hyperwang
Copy link

+1 for this feature, otherwise I need to write scripts to rotate these files.

@yyh-graphsql

This comment has been minimized.

@rockuw

This comment has been minimized.

@chanfr

This comment has been minimized.

1 similar comment
@elithnever

This comment has been minimized.

@saifhhasan
Copy link

Any updates on this feature ?

@grahamkenville

This comment has been minimized.

@bartsimpson89

This comment has been minimized.

4 similar comments
@hiendsoft

This comment has been minimized.

@nevermore-muyi

This comment has been minimized.

@kubeway

This comment has been minimized.

@bitkevin

This comment has been minimized.

@sergiud
Copy link
Collaborator

sergiud commented Jun 6, 2018

Locking the issue due to spam.

@google google locked as spam and limited conversation to collaborators Jun 6, 2018
@sergiud sergiud closed this as completed Mar 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests