Is it possible to have 2 Error Logs per VirtualHost in Apache?
No, it is not possible to have two ErrorLog directives per VirtualHost. However, you could use Apache's ability to pipe to a command in order to log to two (or more) files using the UNIX 'tee' command:
ErrorLog "|/usr/bin/tee -a /var/log/apache/error-1.log /var/log/apache/error-2.log"
According to the Apache 2.4 Logs documentation:
By default the piped log process is spawned without invoking a shell. Use "|$" instead of "|" to spawn using a shell (usually with /bin/sh -c):
This was the default behaviour for Apache 2.2.
Example:
# Write to files error-1.log and error-2.log, and echo to stdout
CustomLog "|$/usr/bin/tee -a /var/log/apache/error-1.log /var/log/apache/error-2.log"
Another issue I ran into:
- You should not have a space between the Double-Quote and Bar.
-
"|$ ...
is valid. -
" |$ ...
is not.
-