如何阻止 Dovecot 记录到系统日志

如何阻止 Dovecot 记录到系统日志

我运行的是 Ubuntu 16.04,其中安装了用于 imap 的 Dovecot 软件包和用于其 Web 界面的 Roundcube。一切都运行正常,只是我无法让 Dovecot 停止将 imap 登录和 imap 注销记录到 syslog。

/etc/rsyslog.d/50-defaults.conf:

#  Default rules for rsyslog.
#
#                       For more information see rsyslog.conf(5) and /etc/rsyslog.conf

#
# First some standard log files.  Log by facility.
#
auth,authpriv.*                 /var/log/auth.log
*.*;auth,authpriv.none          -/var/log/syslog
# cron.*                                /var/log/cron.log
#daemon.*                       -/var/log/daemon.log
kern.*                          -/var/log/kern.log
#lpr.*                          -/var/log/lpr.log
mail.*                          -/var/log/mail.log
& ~
#user.*                         -/var/log/user.log

#
# Logging for the mail system.  Split it up so that
# it is easy to write scripts to parse these files.
#
mail.info                       -/var/log/mail.info
mail.warn                       -/var/log/mail.warn
mail.err                        -/var/log/mail.err
mail.none                       /var/log/syslog

#
# Logging for INN news system.
#
news.crit                       /var/log/news/news.crit
news.err                        /var/log/news/news.err
news.notice                     -/var/log/news/news.notice

#
# Some "catch-all" log files.
#
#*.=debug;\
#       auth,authpriv.none;\
#       news.none;mail.none     -/var/log/debug
#*.=info;*.=notice;*.=warn;\
#       auth,authpriv.none;\
#       cron,daemon.none;\
#       mail,news.none          -/var/log/messages

#
# Emergencies are sent to everybody logged in.
#
*.emerg                                :omusrmsg:*

#
# I like to have messages displayed on the console, but only on a virtual
# console I usually leave idle.
#
#daemon,mail.*;\
#       news.=crit;news.=err;news.=notice;\
#       *.=debug;*.=info;\
#       *.=notice;*.=warn       /dev/tty8

# The named pipe /dev/xconsole is for the `xconsole' utility.  To use it,
# you must invoke `xconsole' with the `-file' option:
#
#    $ xconsole -file /dev/xconsole [...]
#
# NOTE: adjust the list below, or you'll go crazy if you have a reasonably
#      busy site..
#
# daemon.*;mail.*;\
daemon.*;
        news.err;\
        *.=debug;*.=info;\
        *.=notice;*.=warn       |/dev/xconsole

# Don't log Dovecot logins
:msg, contains, "imap-login" ~

/etc/rsyslog.conf:

#  /etc/rsyslog.conf    Configuration file for rsyslog.
#
#                       For more information see
#                       /usr/share/doc/rsyslog-doc/html/rsyslog_conf.html
#
#  Default logging rules can be found in /etc/rsyslog.d/50-default.conf


#################
#### MODULES ####
#################

module(load="imuxsock") # provides support for local system logging
module(load="imklog")   # provides kernel logging support
#module(load="immark")  # provides --MARK-- message capability

# provides UDP syslog reception
#module(load="imudp")
#input(type="imudp" port="514")

# provides TCP syslog reception
#module(load="imtcp")
#input(type="imtcp" port="514")

# Enable non-kernel facility klog messages
$KLogPermitNonKernelFacility on

###########################
#### GLOBAL DIRECTIVES ####
###########################

#
# Use traditional timestamp format.
# To enable high precision timestamps, comment out the following line.
#
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat

# Filter duplicated messages
$RepeatedMsgReduction on

#
# Set the default permissions for all log files.
#
$FileOwner syslog
$FileGroup adm
$FileCreateMode 0640
$DirCreateMode 0755
$Umask 0022
$PrivDropToUser syslog
$PrivDropToGroup syslog

#
# Where to place spool and state files
#
$WorkDirectory /var/spool/rsyslog

#
# Include all config files in /etc/rsyslog.d/
#
$IncludeConfig /etc/rsyslog.d/*.conf

doveconf -n 的输出:

# 2.2.22 (fe789d2): /etc/dovecot/dovecot.conf
# Pigeonhole version 0.4.13 (7b14904)
# OS: Linux 4.4.0-112-generic x86_64 Ubuntu 16.04.3 LTS ext4
auth_mechanisms = plain login
log_path =
mail_location = maildir:/var/mail/vmail/%d/%n
mail_plugins = " quota"
mail_privileged_group = vmail
managesieve_notify_capability = mailto
managesieve_sieve_capability = fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy include variables body enotify environment mailbox date index ihave duplicate mime foreverypart extracttext
namespace inbox {
  inbox = yes
  location =
  mailbox Drafts {
    auto = subscribe
    special_use = \Drafts
  }
  mailbox Junk {
    auto = subscribe
    special_use = \Junk
  }
  mailbox Sent {
    auto = subscribe
    special_use = \Sent
  }
  mailbox "Sent Messages" {
    special_use = \Sent
  }
  mailbox Trash {
    auto = subscribe
    special_use = \Trash
  }
  prefix =
}
passdb {
  args = /etc/dovecot/dovecot-sql.conf.ext
  driver = sql
}
plugin {
  quota = maildir:User quota
  quota_grace = 10%%
  quota_rule = *:storage=5G
  quota_rule2 = Trash:storage=+100M
  quota_status_overquota = 552 5.2.2 Mailbox is full
  sieve = ~/.dovecot.sieve
  sieve_after = /etc/dovecot/sieve/spamfilter.sieve
  sieve_dir = ~/sieve
}
postmaster_address = [email protected]
protocols = " imap lmtp sieve"
service auth {
  unix_listener /var/spool/postfix/private/auth {
    group = postfix
    mode = 0666
    user = postfix
  }
}
service imap-login {
  inet_listener imaps {
    port = 993
    ssl = yes
  }
}
service lmtp {
  unix_listener /var/spool/postfix/private/dovecot-lmtp {
    group = postfix
    mode = 0600
    user = postfix
  }
}
ssl = required
ssl_cert = </etc/letsencrypt/live/my.domain.name.here/fullchain.pem
ssl_key = </etc/letsencrypt/live/my.domain.name.here/privkey.pem
userdb {
  args = /etc/dovecot/dovecot-sql.conf.ext
  driver = sql
}
protocol lmtp {
  mail_plugins = " quota sieve"
}
protocol lda {
  info_log_path =
  log_path =
  mail_plugins = " quota sieve"
  postmaster_address = [my own e-mail address]
  syslog_facility = mail
}
protocol imap {
  info_log_path =
  log_path =
  mail_plugins = " quota imap_quota"
  syslog_facility = mail
}

# systemctl restart dovecot rsyslog没有帮助。

在 syslog 和 mail.log 中都会记录的内容以及我希望仅记录在 mail.log 中的内容:

Feb 22 10:00:31 n40l dovecot: imap-login: Login: user=<[email protected]>, method=PLAIN, rip=::1, lip=::1, mpid=16286, secured, session=<eg2dRsllCusAAAAAAAAAAAAAAAAAAAAB>
Feb 22 10:00:31 n40l dovecot: imap([email protected]): Logged out in=91 out=928

附注:cron 仍然坚持记录到 syslog,也无法停止。不确定是否有相同的原因。

问题:如何让 Dovecot 仅记录到邮件日志设备而不记录到系统日志?

答案1

通过以下方式创建完整配置:

doveconf -a > fullconfig.txt

在其中查找具有作为目的地的隐式日志记录选项= syslog

将所有不需要的更改为= /dev/null

答案2

老问题但答案可能仍然对某些人有帮助。

要停止记录到 /var/log/syslog,您应该将 mail.none(和 cron.none)添加到 rsyslog 行,使其变为:

*.*;auth;authpriv.none;mail.none;cron.none          -/var/log/syslog

https://superuser.com/questions/1060190/what-does-the-none-suffix-mean有关“无”后缀的详细信息

答案3

/var/log/mail.log强制调试和信息消息仅登录,syslog不再登录

# /etc/dovecot/conf.d/10-logging.conf
debug_log_path = /var/log/mail.log
info_log_path = /var/log/mail.log

相关内容