I'm trying to write a Filter that handles writing a W3C-compliant log file based on a special set of criteria. I have found most of the needed information in GetServerVariables(), but I still need the following things:
sc-status: The status code returned by the server on the request (i.e. 200 if the HTTP request was OK)
sc-substatus: Substatus code, it's an entry in the current IIS log files and I'd like to keep it
sc-win32-status: Appears to always be 0, but I'll keep it if I can.
sc-bytes: The number of bytes sent back to the client as the response.
time-taken: The amount of time it took IIS internally to process and complete the request.
If anyone can help me with the necessary calls to get these values, that would be wonderful. They are values in the normal IIS log files when W3C is selected, so I feel like they must be available.
You can do it the EASY way or the HARD way. :-) I'll provide you the info; you pick.
The info you want can be found in the HTTP_FILTER_LOG structure available in the SF_NOTIFY_LOG ISAPI Filter event.
typedef struct _HTTP_FILTER_LOG
const CHAR * pszClientHostName;
const CHAR * pszClientUserName;
const CHAR * pszServerName;
const CHAR * pszOperation;
const CHAR * pszTarget;
const CHAR * pszParameters;
} HTTP_FILTER_LOG, *PHTTP_FILTER_LOG;
The SF_NOTIFY_LOG event happens right before IIS is about to write the log entry for that request. The members of HTTP_FILTER_LOG are read/write, so it should be trivial for you to use it for custom logging purposes.
What are the benefits of using HTTP_FILTER_LOG?
The only thing that is missing is sc-substatus, and it cannot be retrieved in ISAPI Filter.
If you insist on doing it the hard way: