Ricardo_arg
Ricardo_arg

Reputation: 520

GLOG - no output file log is created

i am tryng to implement the GLOG lib in my project, but i am only getting console outputs, and i cannot allow to create the file log with the severity asociated, here is my code: i am developing for linux (ubuntu)

#include <glog/logging.h>
int main(int argc, char *argv[])
{

    google::SetLogDestination(0,"/home/ricardo/Desktop/CODIGO/info.log");
    google::SetLogDestination(google::WARNING,"");
    FLAGS_logtostderr = 1;
    google::InitGoogleLogging("log_test");
    LOG(INFO) << "Found " << 2332 << " cookies";

     return 0;

}

any help?? thx in advance!

Upvotes: 3

Views: 9944

Answers (2)

ferrouswheel
ferrouswheel

Reputation: 3786

Instead of FLAGS_logtostderr = 1; you want FLAGS_alsologtostderr=1;

This will log to both a log file and to stderr.

Upvotes: 4

NicholasM
NicholasM

Reputation: 4673

The line google::SetLogDestination(google::WARNING,""); looks pretty suspicious.

This line:

FLAGS_logtostderr = 1;

tells Glog to write to the console, instead of a file. For details, see the section entitled Setting Flags in Google Log's how-to document: http://google-glog.googlecode.com/svn/trunk/doc/glog.html

If you want to write to a file, delete the line containing FLAGS_logtostderr.

Also, why not use INFO instead of 0 in the first case? It would make it clearer.

Upvotes: 4

Related Questions