I am trying to use syslog()
and reading through the man pages tells me that in openlog()
, "The facility argument establishes a default to be used if none is specified in subsequent calls to syslog()
"
So from what I understand, the way to do it is : 1. Call openlog
to set the facility 2. Call syslog()
to log. 3. Call closelog()
.
But what if I do not call openlog() before calling syslog()? What is the facility then? What is meant by "establishes a default to be used if none is specified". Where can one be specified, if not openlog()
?
Aah I think I got it. I think what it means is that for
syslog(int priority, const char *message, ...);
here priority can be multiple flags, as given in the freebsd man page example :
syslog(LOG_INFO|LOG_LOCAL2, "foobar error: %m");
Here the facility is LOG_LOCAL2 and priority is LOG_INFO. So the facility mentioned in openlog() will take effect if none is provided in a call to syslog() as above.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.