4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Rsyslogでタイムスタンプをメッセージとして送信すると一部消える

Posted at

こんなメッセージを送る

2023-10-05 10:35:15 メッセージ

メッセージ内容だけをログに保存させる

50-default.conf
$template CustomTemplate,"%msg%\n"
action(type="omfile" file="/var/log/message.log" template="CustomTemplate")

しかしログに年月日と時間が保存されてない!!

実際に保存されるログ

35:15 メッセージ

原因

年月日がホスト名、時間がログのタグ(systemd[1]:など)として扱われるため

対処方法

メッセージテンプレートでホスト名とログのタグを組み込むことで年月日と時間が保存されるようになる

# %年月日% %%%: メッセージ%\n
$template CustomTemplate,"%hostname% %syslogtag%%msg%\n"
action(type="omfile" file="/var/log/message.log" template="CustomTemplate")
4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?