2

I am writing syslog using GLOG using GLOG documentation For example I have following code :

 SYSLOG(INFO)<<"Syslog testing";

but int log file I see

 Nov 18 16:39:03 xyz UNKNOWN[12807]: Syslog testing

Can anybody please tell me Is there any way to change UNKNOWN to my input string?.

rovy
  • 2,481
  • 5
  • 18
  • 26

1 Answers1

0

This happens because you haven't initialized GLOG yet. Before calling anything in the glog lib, run the InitGoogleLogging function. The documentation states you should pass argv[0] from main (see https://github.com/google/glog), which should be the name of your executable. However, you can pass what you desire here and that is what you will see in syslog.

e.g.

google::InitGoogleLogging("MyProgramName");
SYSLOG(INFO) << "Starting my program!";

result:

Apr 29 18:38:28 ccc39bda5f31 MyProgramName[2927]: Starting my program!
mitchellJ
  • 734
  • 3
  • 9
  • 32