我々は、ログファイルを回転させるためにLinux logrotateを使用します。
例:
/location/tomcat/logs/* /location/jboss/log/* {
copytruncate
daily
rotate 10
compress
size 20M
olddir rotated
create 0644 test test
}
LINUXで提供されるコピー切り捨ての定義によると、
copytruncate
Truncate the original log file in place after creating a copy,
instead of moving the old log file and optionally creating a new
one, It can be used when some program can not be told to close
its logfile and thus might continue writing (appending) to the
previous log file forever. Note that there is a very small time
slice between copying the file and truncating it, so some log-
ging data might be lost. When this option is used, the create
option will have no effect, as the old log file stays in place.
そのため、循環中にログファイルのデータが失われます。約5〜20秒ほどログが失われたことがわかりました。データを失うことなく同じプロセスを実行する方法/構成はありますか?
ベストアンサー1
syslog-ngでは、変数を使用して日付などの項目を含めるように出力ファイル名を設定できるため、失われることなく新しい日の午前12時に自動的に新しいファイルの書き込みを開始できることがわかります。
ただし、syslogプログラムをsyslog-ngに変更する必要があります。しかし、柔軟性が必要なようです。