Hi,
I have been working on making the error log format configurable. It's more
or less working now, but I could use some feed-back about the config
syntax. The difficulty is that many tokens only produce output in some
situations (e.g. no remote IP in server scope, no thread id in a
non-threaded MPM, etc.). Since we don't want to have many empty []s or
"-"s in the log, such tokens should take a prefix and suffix that are only
printed if there is some relevant data. Also, some tokens need an
additional argument (e.g. time format, header name, ...).
Due to cut'n'paste from mod_log_config, the currently implemented syntax is
this:
%{arg}{prefix}{suffix}T
This results in rather ugly configuration lines. For example the format
ErrorLogFormat prefix "[%{u}t] [%l] [pid %P%{:tid }T] %F: %{}{: }E%{[client }{]
}a"
ErrorLogFormat suffix "%{Referer}{, referer: }i"
gives roughly what we currently have in trunk:
[Mon Jul 19 23:41:17.073289 2010] [debug] [pid 19220:tid 4132666224]
http_request.c(300): (42)Broken Pipe: [client 127.0.0.1:36119] something's
broken, referer: http://blah.com/
One could use different separators:
%<prefix>{arg}<suffix>T
which would lead to things like
ErrorLogFormat prefix "[%{u}t] [%l] [pid %P%<:tid >T] %F: %<><: >E%<[client ><]
>a"
ErrorLogFormat suffix "%<, referer: >{Referer}< >i"
which is a bit better but not really good. Or maybe:
%<prefix>{arg}T<suffix>
resulting in
ErrorLogFormat prefix "[%{u}t] [%l] [pid %P%<:tid >T] %F: %E<: >%<[client >a<]
>"
ErrorLogFormat suffix "%<, referer: >{Referer}i< >"
Does anyone have a better idea?
BTW, I have also implemented once per request and once per connection
logging and log ids that can be used to connect different lines in the
error log and the error log with the access log. For example, this format
ErrorLogFormat prefix "[%{uc}t] [%m:%l] %{}{req:}{ }L%{C}{conn:}{ }L"
ErrorLogFormat suffix ""
ErrorLogFormat connection "[pid %P] local: %A <-> remote: %a"
ErrorLogFormat request "request %k on connection %{c}L %{Referer}{Referer:
}i"
gives this output, which should be rather nice for debugging:
[2010-07-19 23:35:45.076082] [core:notice] Command line:
'/usr/local/apache2/bin/httpd'
[2010-07-19 23:35:46.832314] [-:-] conn:ruMCWgQNaAo [pid 18932] local: 127.0.0.1:8081
<-> remote: 127.0
.0.1:49804
[2010-07-19 23:35:46.832367] [-:-] req:VOMCWgQNaAo request 0 on connection ruMCWgQNaAo
[2010-07-19 23:35:46.832382] [http:trace4] req:VOMCWgQNaAo Headers received from client:
[2010-07-19 23:35:46.832382] [http:trace4] req:VOMCWgQNaAo Connection:
Keep-Alive
...
[2010-07-19 23:35:46.833359] [-:-] req:secCWmQNaAo request 1 on connection ruMCWgQNaAo
[2010-07-19 23:35:46.833385] [http:trace4] req:secCWmQNaAo Headers received from client:
The patch is available at
http://people.apache.org/~sf/errorlog_format_v1.diff . It still needs some
polishing and cleanup, though.
Cheers,
Stefan