Take the 2-minute tour ×

I am looking to create an Apache module that performs a few extra tasks whenever anything is written out to the Apache error log. What hook(s) do I need to handle?

Update A little more information on what I am trying to do: I have a proprietary logging component that aggregates error messages from several servers, in different environments and frameworks - Linux, PHP, Windows 03/08, .NET 2/4 etc... The .NET components are completed and I believe an Apache module is the route to go on the LAMP side. Whenever Apache hears an error, it will forward it on to a web service I have already created.

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

You could just pipe the errorlog to a program:

ErrorLog "|/path/to/yourscript.pl >>/var/log/apache2/error.log"

yourscript.pl could be a small Perl program. Important is that it keeps running until STDIN is finished (so don't parse one line and quit, the program will only be called once when apache starts)


$|=1; # Don't buffer
print while <STDIN>;
share|improve this answer
add comment

For keeping things simple, I would recommend Konerak's answer.

If you really want to go the module route and delve into the source code and write your own logger handler module, the apache source code make use of libapr, which has the ap_hook_log_transaction register function. It's used in a few places inside the source code:

corey@localhost ~/httpd-2.2.21 $ grep -Rl ap_hook_log .

Assuming you write your own module, compile it, and load it into your apache configuration, it is my understanding that you can intercept a logging event, do something with it, and either pass it along to the next hook, or stop it right there.

Hope this helps.

share|improve this answer
I think I may misunderstood Konerak's answer and had to reread it after your comment. I've been able to locate a lot more information that looks promising based on your answer. –  Jeff Jan 6 '12 at 15:46
add comment

Your Answer


