syslog Tips

1、UNIX C系统编程

#include <syslog.h>
void openlog(const char *ident, int option, int facility);
void syslog(int priority, const char *format, ...);
void closelog(void);
int setlogmask(int maskpri);    //返回值:前日志记录优先级屏蔽字值

  调用openlog是可选择的。如果不调用openlog,则在第一次调用syslog时,自动调用openlog。调用closelog也是可选择的,因为它只是关闭曾被用于与syslog守护进程进行通信的描述符。

2、系统命令

walker@walker-host:~$ logger --help

Usage:
 logger [options] [message]

选项:
 -d, --udp             use UDP (TCP is default)
 -i, --id              log the process ID too
 -f, --file <file>     log the contents of this file
 -h, --help            display this help text and exit
 -n, --server <name>   write to this remote syslog server
 -P, --port <number>   use this UDP port
 -p, --priority <prio> mark given message with this priority
 -s, --stderr          output message to standard error as well
 -t, --tag <tag>       mark every line with this tag
 -u, --socket <socket> write to this Unix socket
 -V, --version         output version information and exit

3、日志文件位置。

1)、CentOS 5.11

/var/log/messages

2)、Ubuntu 14.04

/var/log/syslog

4、配置文件位置。

1)、CentOS 5.11

/etc/syslog.conf

2)、Ubuntu 14.04

(1)、主配置文件。

/etc/rsyslog.conf

(2)、子配置文件。

/etc/rsyslog.d/*.conf


*** walker ***


你可能感兴趣的:(message,conf,syslog,rsyslog)