I have about 10 VirtualHosts and I like to keep the error_logs separated. Recently, I need to also have the error_logs all combined for some mod_security scanning.

If I define 2 ErrorLogs for a test VirtualDomain, I notice that no error's are being logged. Pretty strange.

Is it possible to have a CustomLog play the role of an ErrorLog?

Or am I defining my 2 ErrorLogs incorrectly?

    ServerName mydomain.net
    ServerAlias www.mydomain.net mydomain.net
    DocumentRoot /var/www/html/mydomain
    ServerAdmin not@available.com
    UseCanonicalName Off

    ErrorLog logs/mydomain.net-error_log
    ErrorLog logs/unified_modsecurity-error_log

    CustomLog logs/mydomain.net-access_log combined
    UserDir disabled
    UserDir enabled mydomainuser

2 Answers 2


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"

  • I will try this. If I were to do ErrorLog "|/usr/bin/tee -a /var/log/httpd/mydomain.net-error_log /var/log/httpd/unified_modsecurity-error_log", will the logs still roll over like how they do today?
    – Pat
    Sep 6, 2013 at 0:49
  • 1
    facepalm logrotate should take care of the rotations. I'll give your solution a try, thanks!
    – Pat
    Sep 6, 2013 at 2:16
  • Works like a charm!
    – Ron
    Jan 22, 2019 at 15:42
  • I works also for access log. You can add combined at the end, after double quotes.
    – jobima
    Feb 7, 2019 at 15:02

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.


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.