I can pump messages into with a syslogtag using the following from the command line using the -t option:

myprogram | logger -t MYTAG

And later filter based on that tag:

:syslogtag, contains, "MYTAG" /var/log/mylog

In the above example I am pumping stdout to the logger utility. However, I would like to push messages with that tag directly from myprogram to syslog but I can't seem to find anything related to adding tags in the syslog documentation.

Using the following call:

#include <syslog.h>
syslog(LOG_DAEMON | LOG_DEBUG, "mymessage");

The syslogtag simply ends up being:


Simple misunderstanding - before calling the syslog function I have to use the openlog function:


That does it!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.