I am trying to write a simple apache piped logging directive and I am getting a failure. I just want to grep out 200 response codes for centralizing my log files to ELK. This is the custom log format that I created.
LogFormat "%s %h %l %u %t \"%r\" %b" remove
Here is the piped log
CustomLog "|/bin/grep -v '^200' /var/log/apache2/pi-mirror.com/access.log" remove
I get the following error in the apache2 error log.
AH00106: piped log program '/bin/grep -v '^200' /var/log/apache2/pi-mirror.com/access.log' failed unexpectedly
I cannot seem to figure out what is going on here. I read through apaches docs on piped logging and I can't find anything that I could be doing incorrectly.
This is running on Apache2 2.4.7
Thanks in advance for the assistance.
NOTE
Looking into this further I found that apache 2.2 and apache 2.4 changed the way this is done. Previously a shell was spawned automatically but in the new 2.4 version you must manually specify a shell. As a result I changed my syntax to this
CustomLog "|$/bin/grep -v '^200' /var/log/apache2/pi-mirror.com/access.log" remove
This change has done the following. For some reason when I restart apache2 it spits out all the output of that command to stdout and I see it all from my terminal. But then it fails with the same error message. It's almost like apache is failing to actually start this repetitively which makes me wonder if I need to do something else to fix this.