← 返回命令列表

Linux command

logger 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Example

logger [message]

Example

echo [message] | logger

Example

echo [message] | logger -n [hostname] -P [port]

Example

echo [message] | logger -t [tag]

Example

echo [message] | logger -p user.warning

说明

logger adds entries to the system log (syslog). It is useful for logging from shell scripts or adding custom messages to system logs for debugging and monitoring.

参数

-n, --server HOST
Send to remote syslog server
-P, --port PORT
Remote server port (default: 514)
-t, --tag TAG
Mark messages with tag (default: username)
-p, --priority PRIORITY
Log priority (facility.level, default: user.notice)
-s, --stderr
Also output to stderr
-f, --file FILE
Log contents of file
-i
Include process ID

FAQ

What is the logger command used for?

logger adds entries to the system log (syslog). It is useful for logging from shell scripts or adding custom messages to system logs for debugging and monitoring.

How do I run a basic logger example?

Run `logger [message]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -n, --server HOST do in logger?

Send to remote syslog server