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).
auth: 使用者授權
authpriv: 授權和安全
cron: 計劃任務
daemon: 系統守護程序
kern: 與核心有關的資訊
lpr 與列印服務有關的資訊
mail 與電子郵件有關的資訊
news 來自新聞伺服器的資訊
syslog 由syslog生成的資訊
user 使用者的程式生成的資訊,預設
uucp 由uucp生成的資訊
local0~7 用來定義本地政策
level:
alert 需要立即采取動作
crit 臨界狀态
debug 調試
emerg 系統不可用
err 錯誤狀态
error 錯誤狀态
info 正常消息
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/.