2016-04-18 6 views
1

ログ回転の動作を理解するには、あなたの助けが必要です。複数の場所で定義されたルールのログの振る舞い

logrotate.conflogrotate.dディレクトリで

# see "man logrotate" for details 
# rotate log files weekly 
weekly 

# keep 4 weeks worth of backlogs 
rotate 4 

# create new (empty) log files after rotating old ones 
create 

# use date as a suffix of the rotated file 
dateext 

# uncomment this if you want your log files compressed 
#compress 

# RPM packages drop log rotation information into this directory 
include /etc/logrotate.d 

# no packages own wtmp and btmp -- we'll rotate them here 
/var/log/wtmp { 
    monthly 
    create 0664 root utmp 
    minsize 1M 
    rotate 1 
} 

/var/log/btmp { 
    missingok 
    monthly 
    create 0600 root utmp 
    rotate 1 
} 

# system-specific logs may be also be configured here. 

、私は、例えば一つのファイルには、consul-logを求めている:/var/lib/logrotate.status

/var/log/consul { 
    size 500M 
    missingok 
    rotate 0 
    compress 
    notifempty 
    copytruncate 
}  

、私はこれらの行は(領事ログに関連する見ることができるファイルファイル):

logrotate state -- version 2 
"/var/log/consul" 2016-1-25 

私の質問は:

  1. 私はlogrotate.conf内部rotate 4を持っていますが、私はlogrotate.d/consul-log内部rotate 0を持っている場合は、使用rotate 0またはrotate 4をのlogrotateのだろうか?あなたの質問に関しては

答えて

1

私はlogrotate.confrotate 4を持っていますが、私はlogrotate.d/consul-logrotate 0を持っている場合は、使用rotate 0またはrotate 4をのlogrotateのだろうか?

logrotate.confあなたはlogrotate.dフォルダ内に作成し、システム全体の変更や他のコンフィギュレーションファイル用の設定ファイルが上書きされますです。そのため、このディレクティブの

# RPM packages drop log rotation information into this directory 
include /etc/logrotate.d 
+0

あなたのanswwerのおかげで –

0

/var/log/consulために、それはrotate 0を使用します。引用man pageから:

各設定ファイルには、グローバルオプションを設定する(ローカル定義はグローバルなものをオーバーライドし、以降の定義は、以前のものを上書き)して回転するログファイルを指定することができます。

あなたの場合、rotate 0はローカルでも後でもあります。

関連する問題