Can't get apache24 ErrorLog to log to syslog

I have an apache server that I want to set up for logging to syslog. I successfully set up the access logs to be sent to syslog, but for some reason it doesn't work for ErrorLog.

It always logs to /var/log/httpd-error.log no matter what I put in the apache config. CustomLog works fine, though.

I'm running Apache/2.4.43 installed from Packages on FreeBSD 12.1.

I made sure the global ErrorLog directive is commented out in httpd.conf:

Apache config:
#ErrorLog "/var/log/httpd-error.log"

I am putting this in each vhost config:

Apache config:
ErrorLog "|/usr/bin/logger -t httpd-app1-error -p local6.info"

The ErrorLog directive works fine if I specify a filename (e.g. /var/log/httpd-app1-error.log) - it just doesn't seem to work with piped logging whereas CustomLog works with either file logging or piped logging.

Also when i type "ps aux" I do see that apache spawned the pipe command:

Bash:
# ps aux | grep app1-error
/usr/bin/logger -t httpd-app1-error -p local6.info

It just decides to log to the main /var/log/httpd-error.log though, instead of syslog, for some reason. Any suggestions on how to fix this would be greatly appreciated.
 
Ah yes, there was something...

Code:
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
# Das funktioniert nicht - es wird immer nur ein Errorlog genommen!

ErrorLog syslog:local0

As I noted there, it did not work. Errorlog can go to syslog, but there can be only one. It didn't work with <virtualhost> although it seems to say so. Bug, I suppose.

And the |/usr/bin/logger construct doesn't work with the errorlog, either.
 
Thanks for confirming that it doesn't work properly. Maybe I can set it up to have ErrorLog go to a file for each virtual host, and then set something up to feed those logs into the logger command which goes to syslog.
 
After looking at the logs again, it appears the ErrorLog doesn't respect separate filenames for each VirtualHost, but it logs fine to /var/log/httpd-error.log

As a workaround I have another process set up to send the log entries to syslog:

Bash:
/usr/bin/nohup /bin/sh -c 'tail -0F /var/log/httpd-error.log | /usr/bin/logger -t httpd-error -p local6.info' &
 
After looking at the logs again, it appears the ErrorLog doesn't respect separate filenames for each VirtualHost, but it logs fine to /var/log/httpd-error.log

Ah. So it doesn't work with different filenames, just as with different syslog channels.

As a workaround I have another process set up to send the log entries to syslog:

That wouldn't be necessary. A single errorlog can go directly to syslog, as I qouted above.
 
Back
Top