'How to change tag 'UNKNOWN' when doing syslog from GLOG?
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?.
Solution 1:[1]
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!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | mitchellJ |
