logging - Apache 2.4, custom module not respecting ErrorLogFormat -
i have custom c module apache 2.4 (on windows, though hope not relevant). within module write out errors , ap_log_perror. well, error messages log file. recently, tried create custom format error log file using errorlogformat directive, e.g.:
# timestamp (pid:tid) [level] [module] {client} (errorcode) message errorlogformat "%{u}t (%p:%t) [%l] [%m] {%a} (%e) %m"
for standard apache modules, format change works nicely, e.g.:
thu jul 16 17:45:28.521107 2015 (1912:1504) [info] [ssl] {127.0.0.1:52505} ((os 10060)a connection attempt failed because connected party did not respond after period of time, or established connection failed because connected host has failed respond. ) ah01991: ssl input filter read failed. thu jul 16 17:45:28.521107 2015 (1912:1504) [debug] [ssl] {127.0.0.1:52505} ah02001: connection closed child 98 standard shutdown (server myhost.meditech.com:443)
for custom module, however, format default:
[thu jul 16 17:45:28.821350 2015] [my_mod:notice] [pid 1912:tid 1488] onmessage:begin
i've followed path through apache's source , found main logging facility kick in, if can find log format (and it's not startup message):
if (log_format && !info.startup) { len += do_errorlog_format(log_format, &info, errstr + len, max_string_len - len, &errstr_start, &errstr_end, fmt, args); }
and furthermore, log_format set such:
if (s->module_config) { sconf = ap_get_core_module_config(s->module_config); ... log_format = sconf ? sconf->error_log_format : null; ...
i cannot compile apache (having trouble doing so), did throw logic module pull in s->module_cong->error_log_format , verified it's custom list of tokens, etc.
i took @ couple standard modules , played around defining merged configs , such (before learned they're used for) no dice.
any thoughts? realize there other workarounds piping log program, etc. should able have module behave standard ones in regard.
thanks
p.s. in case it's interesting, typical call log mod looks like:
request_rec *r = server->request(server); ... ap_log_perror(aplog_mark,aplog_notice,0,r->pool,"onmessage:begin");
don't use ap_log_perror(), has no context apply per request or server config. use ap_log_rerror when have request_rec* in context (which dereferencing anyway).
generally, use ap_log_rerror when have request_rec, , ap_log_cerror when have conn_rec. ap_log_error server_rec or "ap_server_conf".
Comments
Post a Comment