Forum Moderators: phranque

Message Too Old, No Replies

log only the requests of status code = 200

         

alluoshi

8:08 pm on May 3, 2009 (gmt 0)

10+ Year Member



Hi, I was looking for conditional logging to log only the requests that have status code = 200. I found the following in the documentation:
--------------------------------------------------
-Remote_Host: the hostname of the client making the request
-Remote_Addr: the IP address of the client making the request
-Server_Addr: the IP address of the server
-Request_Method: the name of the method being used
-Request_Protocol: the name and version of the protocol
-Request_URI:the resource requested on the HTTP request line
----------------------------------------------------------
I didn't find anything about the status code. Any ideas please?

Caterham

5:20 pm on May 4, 2009 (gmt 0)

10+ Year Member



I was looking for conditional logging to log only the requests that have status code = 200

You can't do that with the standard functionality of apache since no module which provides functionality to set set environmental variables acts in the ap_hook_log_transaction phase.

Either you write a tiny module which registers a hook in ap_hook_log_transaction as APR_HOOK_FIRST, evaluates r->status and sets an ENV (apr_table_set(r->subprocess_env, name, value)) accordingly;
-or - you move to piped logging and your external program evaluates the status code prior logging the information into a file.