从命令行写入syslog

如何从命令行将条目写入/var/log/syslog

使用logger命令。

 logger Some message to write 

有几种选择,包括:

 -i Log the process ID in each line -f Log the contents of a specified file -n Write to the specified remote syslog server -p Specify a priority -t Tag the line with a specified tag 

有关该工具的更多信息,请参见man 1 logger

或者,您可以从python写入syslog

 python -c 'import syslog; syslog.syslog("Hello World")'