CentOS 7にdovecotをインストールしました。
デフォルトでログは/var/log/maillogに記録されます。これではpostfixのログと混在して調べる時に手間になったりまします。
今回はdovecotのログを別ファイルに記録する設定です。
Dovecot Logging
https://wiki2.dovecot.org/Logging
設定ファイルは/etc/dovecot/conf.d/10-logging.confです。
- syslog
- ログファイルの指定
- 詳細なログ設定
デフォルトではsyslog経由でsyslog_facilityがmailなので/var/log/maillogに記録されます。
1 2 3 4 5 6 7 8 |
# Log file to use for error messages. "syslog" logs to syslog, # /dev/stderr logs to stderr. #log_path = syslog # Syslog facility to use if you're logging to syslog. Usually if you don't # want to use "mail", you'll use local0..local7. Also other standard # facilities are supported. #syslog_facility = mail |
1 |
mail.* -/var/log/maillog |
これをsyslog_facilityをlocal5でsyslog経由で/var/log/dovecot.logに記録します。
1 2 |
# vi /etc/dovecot/conf.d/10-logging.conf syslog_facility = local5 |
/etc/rsyslog.conに設定を追加します。
1 2 3 4 |
# vi /etc/rsyslog.conf # Dovecot log local5.* -/var/log/dovecot.log |
dovecot reloadします。
1 |
# systemctl reload dovecot |
これで/var/log/dovecot.logに記録されるようになりました。
logrotateはsyslog関連で既に設定されているので、保存期間などの変更が無いならこれで完了です。
下記のlogrotateの設定を行います。
1 2 3 4 5 6 7 8 9 10 11 12 13 |
# vi /etc/logrotate.d/dovecot /var/log/dovecot.log { weekly rotate 4 missingok notifempty compress delaycompress sharedscripts postrotate doveadm log reopen endscript } |
syslogを使用したくない場合はログファイルを指定することもできます。
1 2 3 4 5 6 7 8 9 10 |
# vi /etc/dovecot/conf.d/10-logging.conf # Log file to use for error messages. "syslog" logs to syslog, # /dev/stderr logs to stderr. log_path = /var/log/dovecot.log # Log file to use for informational messages. Defaults to log_path. #info_log_path = # Log file to use for debug messages. Defaults to info_log_path. #debug_log_path = |
info,debug情報をさらに別ファイルに記録する場合はinfo_log_path =,debug_log_path =に指定して下さい。
dovecot reloadします。
1 |
# systemctl reload dovecot |
このままではログが肥大化するのでlogrotateの設定を行います。
1 2 3 4 5 6 7 8 9 10 11 12 13 |
# vi /etc/logrotate.d/dovecot /var/log/dovecot.log { weekly rotate 4 missingok notifempty compress delaycompress sharedscripts postrotate doveadm log reopen endscript } |
上記サイトから取り敢えず引用(^^;
Logging verbosity
There are several settings that control logging verbosity. By default they’re all disabled, but they may be useful for debugging.
auth_verbose=yes enables logging all failed authentication attempts.
auth_debug=yes enables all authentication debug logging (also enables auth_verbose). Passwords are logged as.
auth_debug_passwords=yes does everything that auth_debug=yes does, but it also removes password hiding (but only if you are not using PAM, since PAM errors aren’t written to Dovecot’s own logs).
mail_debug=yes enables all kinds of mail related debug logging, such as showing where Dovecot is looking for mails.
verbose_ssl=yes enables logging SSL errors and warnings. Even without this setting if connection is closed because of an SSL error, the error is logged as the disconnection reason.
auth_verbose_passwords=no|plain|sha1 If authentication fails, this setting logs the used password. If you don’t really need to know what the password itself was, but are more interested in knowing if the user is simply trying to use the wrong password every single time or if it’s a brute force attack, you can set this to “sha1” and only the SHA1 of the password is logged. That’s enough to know if the password is same or different between login attempts.