Where to find Postfix Log Files?

In Ubuntu, postfix is the mail transfer agent for sending emails over the internet connection. It supports a command line interface to send emails faster, more securely, and easy to manage, also compatible with other Unix-like operating systems. The Postfix log files store all the information about failed and successful deliveries of the emails.

This post will demonstrate the location of the postfix log files in Linux.

Note: To install the Postfix on Ubuntu, check our guide here.

Where are the postfix log Files Located?

The Postfix log file is usually located with the name “/var/log/mail.log”, which can be accessed through the sudo permissions. 

$ sudo cat /var/log/mail.log

The “/var/log/mail.log” file is printed.

How to Fix if the Postfix Log File is Deleted/Disappeared?

If, in any scenario, the log file is deleted by the user or not appearing in the directory, as in the below case, our file is deleted:

$ cd /var/log
$ ls
$ cat mail.log

Go through the following steps to restore the “mail.log” file.

Step 1: Install rsyslog

Install the rsyslog (a utility that gives message logging support) in the system through the given command:

$ sudo apt install rsyslog              #For Debian/Ubuntu
$ sudo yum install rsyslog              #For CentOS/RHEL
$ sudo dnf install rsyslog              #For Fedora

The “rsyslog” service is installed.

Note: if you have already installed the “rsyslog” service in the operating system, remove and re-install it using the below command:

$ sudo apt autoremove rsyslog       #For Debian/Ubuntu
$ sudo yum remove rsyslog           #For CentOS/RHEL
$ sudo dnf remove rsyslog           #For Fedora

Step 2: Restart the Postfix and Rsyslog Services 

Then, restart the Postfix and rsyslog as shown:

$ sudo service postfix restart
$ sudo service rsyslog restart

The services for Postfix and rsyslog is restarted.

After performing the above steps, the log file of the Postfix will appear in the directory as shown below:

$ ls

Conclusion

Postfix is the mail transfer agent in Ubuntu that stores all records of the emails in the log file located under the directory “/var/log/mail.log”. If it is deleted by the user or disappears, it can be restored by installing the rsyslog service and restarting the Postfix and rsyslog service. 

This write-up has answered the query, “where are the postfix log files?” and elaborated on the purpose alongside its functionality.