Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change logging directory in Google glog

Tags:

c++

logging

glog

How can I change the output directory in Google glog?

I only found google::SetLogDestination(google::LogSeverity, const char* path)

tried it with:

google::SetLogDestination(ERROR, "C:\\log\\error.log);
google::InitGoogleLogging("Test");  

LOG(ERROR) << "TEST";

but nothing was written!

Btw.: if you suggest another lightweight, easy to use and thread safe library please let me know!

Thx for any help!

like image 637
leon22 Avatar asked Oct 10 '13 09:10

leon22


People also ask

Where does Glog log to?

Unless otherwise specified, glog writes to the filename /tmp/\<program name\>. \<hostname\>. \<user name\>. log.

Is Glog thread safe?

Thread safe useThe default use of goby::glog is not thread safe. To enable thread-safe access (uses a mutex lock/unlock for each call from goby::util::FlexOstream::is to std::endl or std::flush), set (before any concurrent access): goby::glog.


1 Answers

You can also do one of the following:

Pass the log directory as a commandline argument as long as you have the GFlgas library installed:

./your_application --log_dir=/some/log/directory

If you don't want to pass it in the commandline and instead set it in the source:

FLAGS_log_dir = "/some/log/directory";

If the Google gflags library isn't installed you can set it as an environment variable:

GLOG_log_dir=/some/log/directory ./your_application
like image 69
Elias Kouskoumvekakis Avatar answered Sep 28 '22 09:09

Elias Kouskoumvekakis