# Can't get apache24 ErrorLog to log to syslog



## phpdave11 (May 20, 2020)

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:


```
#ErrorLog "/var/log/httpd-error.log"
```

I am putting this in each vhost 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: 


```
# 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.


----------



## PMc (May 21, 2020)

Ah yes, there was something...


```
# 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.


----------



## phpdave11 (May 21, 2020)

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.


----------



## phpdave11 (May 21, 2020)

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:


```
/usr/bin/nohup /bin/sh -c 'tail -0F /var/log/httpd-error.log | /usr/bin/logger -t httpd-error -p local6.info' &
```


----------



## PMc (May 22, 2020)

phpdave11 said:


> 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.


----------

