1、logger命令介绍
a shell command interface to the syslog(3) system log module
用于往系统中写入日志,他提供一个shell命令接口到syslog系统模块
2、logger参数详解
-d, --udp Use datagram (UDP) instead of the default stream connection (TCP). 使用udp链接而不是tcp链接 -i, --id Log the process ID of the logger process with each line. 逐行记录每一次logger的进程ID -f, --file file Log the contents of the specified file. This option cannot be combined with a command-line message. 记录特殊文件的内容,这个参数不能够包含了命令行的信息。 -h, --help Display a help text and exit. 展示帮助信息 -n, --server server Write to the specified remote syslog server using UDP instead of to the builtin syslog routines. 使用udp而不是内置惯例的syslog写的如到特定的远端的syslog服务器 -P, --port port Use the specified UDP port. The default port number is 514. 使用特定的UDP端口,默认的端口是514 -p, --priority priority Enter the message into the log with the specified priority. The priority may be specified numerically or as a facil‐ity.level pair. For example, -p local3.info logs the message as informational in the local3 facility. The default is user.notice. 指定输入消息的优先级,优先级可以是数字或者指定为 " facility.level" 的格式。比如:" -p local3.info " local3 这个设备的消息级别为 info。默认级别是 "user.notice" -s, --stderr Output the message to standard error as well as to the system log. 输出错误到系统日志 -t, --tag tag Mark every line to be logged with the specified tag. 对每行记录最特殊的标记 -u, --socket socket Write to the specified socket instead of to the builtin syslog routines. 写到特定的socket而不是内置惯例的syslog。 -V, --version Display version information and exit. 显示版本信息 **messages:**写入log文件的内容消息时,可以使用-f参数。 logger 以0退出时代表成功,大于0代表失败。
3、logger的用途和日志级别
Valid facility names are: auth, authpriv (for security information of a sensitive nature), cron, daemon, ftp, kern (can‘t be gener‐ated from user process), lpr, mail, news, security (deprecated synonym for auth), syslog, user, uucp, and local0 to local7, inclu‐sive.
Valid level names are: alert, crit, debug, emerg, err, error (deprecated synonym for err), info, notice, panic (deprecated synonym for emerg), warning, warn (deprecated synonym for warning). For the priority order and intended purposes of these levels, see syslog(3).
notice 正常但是要注意
4、 EXAMPLES
logger System rebooted logger -p local0.notice -t HOSTIDM -f /dev/idmc logger -n loghost.example.com System rebooted
5、Others
SEE ALSO
syslog(3), syslogd(8)
STANDARDS
The logger command is expected to be IEEE Std 1003.2 (“POSIX.2”) compatible.
AVAILABILITY
The logger command is part of the util-linux package and is available from ftp://ftp.kernel.org/pub/linux/utils/util-linux/.
本文出自 “思想决定高度” 博客,请务必保留此出处http://chuck.blog.51cto.com/10232880/1717518
原文:http://chuck.blog.51cto.com/10232880/1717518