LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 02-15-2006, 02:47 PM   #1
ganz_friedrich
Member
 
Registered: Dec 2005
Posts: 47

Rep: Reputation: 16
Apache 2.0 | logging | Recording the host name in the log files


Is there any way to record the Host name requested in the access log. (The site has many subdomains and do not want each one to have its own log file.)

I've tried this:

LogFormat "%h %l %u %t \"%r\" \"%{HTTP_HOST}\" %>s %b" commonwh

but for some reason this doesn't work. (On the other hand the %{Referer} variable works - why not %{HTTP_HOST}?).

Thank you.
 
Old 02-16-2006, 02:43 PM   #2
KimVette
Senior Member
 
Registered: Dec 2004
Location: Lee, NH
Distribution: OpenSUSE, CentOS, RHEL
Posts: 1,794

Rep: Reputation: 46
There sure is, and honestly this is an RTFM issue. However here is the solution, borrowed from my kim.httpd.conf:

Code:
LogFormat "%h %l %u %t %v \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" myLogFormat
CustomLog /var/awstats/kim/log/kim.log myLogFormat
where:
%h = host (which is what you're looking to log)
$l = remote log name
%u = username (http authentication, if used)
%t = time of request
%v = the canonical server name (if UseCanonicalName defined gets logged, otherwise a - is substituted)
\"%r\" = the query, method, and http rev (e.g., get /foo.html http/1.1)
%>s = HTTP transfer status code (what it sets in the response header)
%b = bytes transferred
\"%{Referer}i\" = the referrer variable (the site linking to you)
\"%{User-agent}i\" = the user agent variable (the requestor's reported user agent)

myLogFormat = what I named that logfile spec


This line:
CustomLog /var/awstats/kim/log/kim.log myLogFormat
tells the server to write the log to /var/awstats/kim/log/kim.log, and use the myLogFormat spec defined above

Last edited by KimVette; 02-16-2006 at 02:51 PM.
 
Old 02-16-2006, 03:06 PM   #3
ganz_friedrich
Member
 
Registered: Dec 2005
Posts: 47

Original Poster
Rep: Reputation: 16
Actually no, this is not a RTFM situation (or at least it's not obviously there). If you read my question, I wanted the host name that was requested by the client not the client's host name / ip.

Well anyway a little messing around and I found the solution. If anyone else needs it:

1. you need an "i" after these types of "long" variables (as with the others)
2. its not %{HTTP_HOST} as in mod_rewrite conditions, but rather %{Host} (lucky guess

So it should be

LogFormat "%h %l %u %t \"%r\" \"%{Host}i\" %>s %b" commonwh


Thanks
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache Browser Log Files soulestream Linux - Software 1 12-14-2005 02:59 AM
multiple log files in apache Red Squirrel Linux - Software 1 09-27-2005 12:42 AM
pppd logging to /var/log/ppp.log problem mrtwice Linux - Software 1 01-10-2004 05:38 PM
Question on Apache Log Files JLDixon Linux - Software 1 10-12-2003 11:03 AM
Can log files be time stamped? (such as FTP login and transfer log files) bripage Linux - Networking 6 08-08-2002 10:55 PM


All times are GMT -5. The time now is 11:39 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration