How to set the maximum log file size?

2,253 views
Skip to first unread message

dundee

unread,
Jan 13, 2010, 7:38:00 AM1/13/10
to google-glog, I...@cpce.net
Hello.
Is there in the google-glog library possibility to set the maximum
size of the log files? I'm looking for a solution like "RING BUFFER",
so after logging certain number of message, the oldest one is replaced
with the newest one.
Thank you.
Ivan.

shinichiro hamaji

unread,
Jan 14, 2010, 8:49:55 AM1/14/10
to googl...@googlegroups.com

By default, glog starts to create another file every 1.8GB logs. You
can change this value by setting max_log_size parameter. Suppose you
want to change file every 10MB. If you have gflags installed,
--max_log_size=10 should work. Otherwise, you need to set
GLOG_max_log_size=10 environment variable. You can control this value
in your program using FLAGS_max_log_size, too.

I guess setting this value as you like and discarding old log files
would achieve
what you want.

There are some undocumented commandline flags which are rarely used.
You can grep src/logging.cc by DEFINE_ to find this kind of flags.

Thanks,

dundee

unread,
Jan 18, 2010, 3:51:11 AM1/18/10
to google-glog
Thank you for your answer.
This is also helpful hint for me. But I was looking for a solution,
that after certain size of LOG entries (even number of messages of
total size in bytes), the oldest messages are rewritten by the newest
ones. The situation is, that I have limited size of disk space, so I
have to check periodically the size of log directory and "clean" the
oldest files. So I need to use bash script executed periodically from
cron, to clean the disk space and this I would like to avoid.
Thank for your hints.
Ivan.

On Jan 14, 2:49 pm, shinichiro hamaji <shinichiro.ham...@gmail.com>
wrote:

hhi...@gmail.com

unread,
Aug 5, 2013, 5:03:17 AM8/5/13
to googl...@googlegroups.com
Hi shinh ,
Is there any method to control the number the of those log files?


在 2010年1月14日星期四UTC+8下午9时49分55秒,shinh写道:
Reply all
Reply to author
Forward
0 new messages