Search code examples
centos7postfix-mtarsyslogjournal

Postfix Mail Log: Is it possible to prevent some types of daemon/modules events messages from being written to the log?


So, my CentOS 7 server sends emails using Postfix and, for tracking porpuses, i need to make regular checks on the Postfix mail log (/var/log/maillog) to analyse successfull sent messages.

As i understand, postfix mail log receives messages from 4 different types of daemon/module events: - postfix/qmgr - postfix/smtp - postfix/smtpd - postfix/cleanup

  1. In order to make sure that all the messages gets written in the log, i had to remove the rate limits on both /etc/rsyslog.conf and /etc/systemd/journald.conf.

  2. But removing rate limits resulted in significantly increasing of resource usage and on the size of the log files, taking much more time to get the grep results on the logs.

  3. So, one way of relieve the resources usage would be to decrease the logging activity by blocking unwanted types of daemon/module events.

  4. In my particular case, i only need the postfix/smtp daemon/module, therefore the other 3 could be ignored and kept away from the log.

So, my question is: how can i prevent smtpd, cleanup and qmgr daemons events messages from being written to the log, keeping only smtp events?


Solution

  • I made a simple script to try and solve it:

    zgrep status=sent /var/log/maillog*.* > MailsTemp.txt
    zgrep smtp MailsTemp.txt >> ListSentEmails.txt
    rm -f MailsTemp.txt

    Just run a crontab with it at morning and it will sort it out into the file ListSentEmails.txt