How to get module name in log line via ap_log_error in a Apache Module in C?

119 views Asked by At

Would like to get more detail into my error log lines from my apache module.

Currently am using this to log a bad request:

ap_log_error(APLOG_MARK, APLOG_ERR, 400, r->server,"error msg");

Which results in this in the error log file:

[Wed Nov 09 14:17:08.429009 2022] [:error] [pid 765] (400)Unknown error 400: error msg

Would like to have an identifier on the left side of ":error" like the module name and also have "Unknown Error" be more specific like "Bad Request" or file line number if possible. More like the line below plus file and line number if possible:

[Wed Nov 09 13:56:51.902728 2022] [core:notice] [pid 757] AH00094: Command line: '/usr/sbin/apache2'

According to https://svn.apache.org/viewvc/httpd/httpd/trunk/include/http_log.h?view=markup

APLOG_MARK is supposed to be a macro for use as the first three parameters in ap_log_error() and related functions, i.e. file, line, and module_index.

However no file, line or module index are present in my log line.

Thanks

1

There are 1 answers

0
covener On

Apache 2.4 made it standard for modules to have module AP_MODULE_DECLARE_DATA foo_module at the top. The APLOG_MARK macro depends on it.