syslog命令详解 #系统安全
syslog是Linux系统默认的日志守护进程。默认的syslog配置文件是 /etc/syslog.conf
文件。程序,守护进程和内核提供了访问系统的日志信息。因此,任何希望生成日志信息的程序都可以向 syslog 接口呼叫生成该信息。
使用方法
在/var/log中创建并写入日志信息是由syslog协议处理的,是由守护进程sylogd负责执行。每个标准的进程都可以用syslog记录日志。可以使用logger命令通过syslogd记录日志。
要向syslog文件/var/log/messages中记录日志信息:
logger this is a test log line 输出: tail -n 1 messages Jan 5 10:07:03 localhost root: this is a test log line
如果要记录特定的标记(tag)可以使用:
logger -t TAG this is a test log line 输出: tail -n 1 messages Jan 5 10:37:14 localhost TAG: this is a test log line