Forum Moderators: phranque
LogFormat "c %{X-Forwarded-For}i %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined(Note: the initial c/p is just for testing so I can tell at a glance which format is being used to log the request).
LogFormat "p %{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" proxy_log
SetEnvIf X-Forwarded-For 192.168.1.12 proxfor
CustomLog "access" combined env=!proxfor
CustomLog "access" proxy_log env=proxfor
SetEnvIf Remote_Addr 192\.168\.1\.12 proxfor
And I'm getting the exact same results.
Is the custom logging intended to be instead of or in addition to whatever the default is?Instead of.
you're more likely to get the intended results if you begin with the IP ("Remote_Addr" in setenvif-speak)Agree- I've switched to using that instead for further testing:
LogFormat "p %{X-Forwarded-For}i %a %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" c_proxy
LogFormat "c %{X-Forwarded-For}i %a %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
SetEnvIf Remote_Addr "192\.168\.1\.12" proxfor
CustomLog /var/log/apache2/access.log c_proxy env=!proxfor
CustomLog /var/log/apache2/access.log c_proxy env=proxfor
if I don't specify a LogFormat called combined, I get lines of "combined" (without quotes) in the log file.
%{FOOBAR}e
Oh, well that's handy. It offers yet another way to verify that your environmental variable has not only been set, but is recognized by mod_log_config. Why not throw it into both LogFormat definitions to double-check. (Err... This IS all happening on something other than a live site, right?)
...did you at some point try reversing the two LogFormat lines
No matter what, it uses the combined named log format, even though the selections don't allow for it.
This IS all happening on something other than a live site, right?Most definitely yes!
there is perhaps a CustomLog directive somewhere else in the server config?Nope- searched it several times, as well as included files.
Or the server hasn't been restartedIt has been. Each time I made a change:
the LogFormat lines just above are the reverse of the lines specified in the OP.
What happens if you remove (comment-out) all CustomLog lines?No change
And all LogFormat lines?All the lines in the log are nothing but the word "combined."
What happens if you include the bit in LogFormat that names the value of your environmental variable?Yes- it's being set.
Can you physically unplug the server?In all the testing, I was just restarting Apache. For fun, today I also tried shutting down the server and restarting. No change. And the server is actually a VM, so unplugging would mean taking some live sites offline.
Does the server simply dislike the specific names being given to the logging formats?I tried several different names. No matter what, it seems to only want to use the one called combined.
it seems to only want to use the one called combined
What does it use if there is nothing called "combined"?That's the case where it just prints "combined" in the log file (no actual data).
If you set it up to write to two separate log filesIt ignored and continued to write everything to the default log (although it did create empty files with those names).
That's the case where it just prints "combined" in the log file (no actual data).
It ignored and continued to write everything to the default log (although it did create empty files with those names).
what happens if you change your "combined" nickname to something elseThat's the case where it just prints "combined" in the log file (no actual data).
is all this logging business lying loose in the config file, or is it inside a Virtual Host section that's specific to this site?Lying loose. They are the last lines before
That's the case where it just prints "combined" in the log file (no actual data).
I looked in sites-enabled and the default has the following line in it inside the default VirtualHost section:I would expect things inside envelopes-- including, in this case, the VirtualHosts envelope-- to override things lying loose in config.
CustomLog ${APACHE_LOG_DIR}/access.log combined
SetEnvIf Remote_Addr 192.168.1.10 proxfor
SetEnvIf Remote_Addr "192.168.1.10" proxfor
SetEnvIf Remote_Addr "192\.168\.1\.10" proxfor