syslog输出的log信息可以直接被journald收集
#include <syslog.h>
void syslog(int priority, const char *message, ... /* argument */);
#include <syslog.h>
int main(int argc, char *argv[])
{
syslog(LOG_DEBUG, "hello debug");
syslog(LOG_INFO, "hello info");
syslog(LOG_WARNING, "hello warning");
syslog(LOG_ERR, "hello err");
return 0;
}
以下为syslog定义的日志level:
#define LOG_EMERG 0 /* system is unusable */
#define LOG_ALERT 1 /* action must be taken immediately */
#define LOG_CRIT 2 /* critical conditions */
#define LOG_ERR 3 /* error conditions */
#define LOG_WARNING 4 /* warning conditions */
#define LOG_NOTICE 5 /* normal but significant condition */
#define LOG_INFO 6 /* informational */<