how to print logs into only one file by google glog

3.7k Views Asked by At

I'm now using google glog. When I'm debugging the program, every time the process restart, a new log file generated, identified by the new pid as filename's sufix, like this

ied_config.20131220-142934.4524
ied_config.20131220-171227.3948
ied_config.20131225-170117.7032
ied_config.20131225-170131.5200
ied_config.20131225-171450.7820
ied_config.20131225-172336.4116
ied_config.20131225-172924.6120
ied_config.20131225-173000.2980
ied_config.20131225-173037.1960
ied_config.20131225-173144.7304
ied_config.20131226-095843.1012
smv_client.20131219-082120.7184
smv_client.20131219-162339.5508
smv_client.20131219-163055.6156
smv_client.20131219-163155.4892
smv_client.20131219-163206.5576
smv_client.20131219-163216.6340
smv_client.20131219-163236.6952
smv_client.20131219-163307.7940
smv_client.20131219-163317.4920
smv_client.20131219-163347.6556
smv_client.20131219-163408.5124
smv_client.20131219-163428.2644
smv_client.20131219-163448.6040
smv_client.20131219-163529.6948
smv_client.20131219-163539.1592
smv_client.20131219-163549.3776
smv_client.20131219-172949.5412
smv_client.20131219-173000.4180
smv_client.20131219-173010.7432
smv_client.20131220-170628.636
smv_client.20131220-170930.3904
smv_client.20131226-095841.1296

I want to join these log just into one file for each program, I can't file the configuration for the glog ,any helps?

2

There are 2 best solutions below

2
On

If you want to change the name of log files, you may need to call SetLogDestination():

google::SetLogDestination(google::INFO, "/var/tmp/another_destination.INFO");
0
On

From release 0.5 on May 8, 2021

Allow a log file to be simply named "foobar.log" with no appended string #124

google::SetLogDestination(google::INFO, "/var/tmp/another_destination.INFO"); FLAGS_timestamp_in_logfile_name = false;