logger(1)
システムログにエントリを作成する、syslog(3)へのCLIインターフェース。
https://linux.die.net/man/1/logger
message引数か、標準入力からメッセージを受け取る
code:sh
logger Hello world!
echo Hello world! | logger
code:sh
11月 29 07:13:21 versa iigau4827: Hello world!
11月 29 07:13:31 versa iigau4831: Hello world!
--journald (stdin), --journald=file
systemdのsystemd-journaldのエントリとしてログを作成するオプション
フィールドのフォーマットはsystemd.journal-fields(7)に準拠する必要がある
-p, --priority facility.level
優先度を設定
Enter the message into the log with the specified priority. The priority may be specified numerically or as a facility.level pair. For example, -p local3.info logs the message as informational in the local3 facility. The default is user.notice.
FACILITIES AND LEVELSにfacilityとlevelのペアが書いてある
-t, --tag tag
特定のタグをつける
-f, --file file
特定ファイルの中身をログに流す
code:sh
echo "hello from file" > testlogfile
logger -f testlogfile
# 11月 29 07:32:49 versa iigau5707: hello from file
-n, --server
システムログソケットの代わりに別のSyslogサーバーに書き込む
明示的に--udp, --tcpが指定されない限り、UDP->TCPの順で書き込みが行われる
Write to the specified remote syslog server instead of to the system log socket. Unless --udp or --tcp is specified, logger will first try to use UDP, but if this fails a TCP connection is attempted.
Linuxにおける基本的ログ理論
例
code:sh
logger System rebooted
System rebootedと表示する
code:sh
logger -p local0.notice -t HOSTIDM -f /dev/idmc
code:sh
logger -n loghost.example.com System rebooted