Add timestamp to apache error log

apache-2.4log-filesloggingpostfix

So I keep getting the following error in apache logs:

sendmail: fatal: open /etc/postfix/main.cf: No such file or directory

And I'm trying to figure out where/when it's being attempted, but I can't figure out where in the apache logs I'm supposed to change the conf in order to get this to show more information. Any ideas?

I have the following in my apache2.conf (which I assumed would make it dislay the proper formatting):

ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

Note, I don't want to fix the error itself (aka make it so that the file exists, fix postfix etc.) I just want to know what is trying to execute the sendmail command.

Best Answer

Your apache try to send email. Maybe from PHP or CGI scripts, but not by itself. If the script is chrooted, it can not access to /etc/postfix/main.cf and return the error. You will not see anything in the logs (except on small sites where you will be able to found the URL asked by the user at the same time that the error line).

You can maybe add a custom log (with %{format}t option)[1], but you will not have it in error log.

Edit : You can also redirect the Error log to Syslog to have the date added by syslog : ErrorLog syslog:local1

[1] https://httpd.apache.org/docs/trunk/mod/mod_log_config.html#formats