You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Terry <td...@gmail.com> on 2008/01/11 16:24:57 UTC
[users@httpd] splitting out to different files in customlog in mass vhost
Hello,
My vhost config is at the bottom. Today, it is writing a special log
format for all of my vhosts to a single file. I would like to
separate them out into separate files based on my vhost.map or the
%{HOST}i or something similar. I tried CustomLog
logs/%{HOST}i-access_log but it appears to not honor that variable in
the CustomLog context. Any ideas? I can't do it on the backend
because I need my log files to be in common log format so the hostname
isn't included in that format.
Thanks!
Terry
<VirtualHost 10.0.1.37:80>
ServerAdmin hostmaster@foobar.com
ServerName omajelws04.foobar.com
Include conf/vhost_mass.conf
LogFormat "%{Host}i %h %l %u %t \"%r\" %s %b" vcommon
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Host}i %h %l %u %t \"%r\" %>s %b \"%{Referer}i\"
\"%{User-agent}i\"" vcombined
CustomLog logs/shared_access_log vcombined
CustomLog logs/common_access_log common
RewriteEngine On
RewriteMap lowercase int:tolower
RewriteMap vhost txt:/etc/httpd/conf/vhost.map
RewriteCond %{REQUEST_URI} !^/icons/
RewriteCond %{REQUEST_URI} !^/cgi-bin/
RewriteCond ${lowercase:%{SERVER_NAME}} ^(?:www\.)?(.+)$
RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
RewriteCond ${vhost:%1} ^(/.*)$
RewriteRule ^/(.*)$ %1/$1
RewriteCond %{REQUEST_URI} ^/cgi-bin/
RewriteCond ${lowercase:%{SERVER_NAME}} ^(?:www\.)?(.+)$
RewriteRule ^/(.*)$ /home/%1/cgi-bin/$1 [T=application/x-httpd-cgi]
<Directory "/">
AllowOverride All
</Directory>
</VirtualHost>
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] splitting out to different files in customlog in mass vhost
Posted by Terry <td...@gmail.com>.
I may have made it a bit further but need some fine tuning:
LogFormat "%{Host}i %h %l %u %t \"%r\" %>s %b" vlogger
CustomLog "| /usr/local/sbin/vlogger /var/log/httpd/test" vlogger
The only problem I have is that %{Host}i contains the literal host
that they typed in. So, they could either type in foobar.com and
www.foobar.com and it gets put into separate directories. In my
config, I have mapping like this:
Include conf/vhost_mass.conf
RewriteEngine On
RewriteMap lowercase int:tolower
RewriteMap vhost txt:/etc/httpd/conf/vhost.map
I thought I could maybe do %{vhost :%1} in my LogFormat but it isn't
reading it in. Any other ideas?
On Jan 11, 2008 12:20 PM, Terry <td...@gmail.com> wrote:
> I can't include the host header in the log as it will break our stats
> program which needs common log format. Here is what I have:
>
> RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
> RewriteCond ${vhost:%1} ^(.+)$
> RewriteRule . - [E=%1:1]
> LogFormat "%h %l %u %t \"%r\" %>s %b" common
> CustomLog logs/foobar.com_access.log common env=foobar.com
>
> If I go to foobar.com, it is not showing up in the logs. :\ I
> think you are on the right track though.
>
> On Jan 11, 2008 10:11 AM, Axel-Stephane SMORGRAV
>
> <Ax...@europe.adp.com> wrote:
> > I can basically see two ways of doing this:
> >
> > 1. Include the host header in the log and use a script to split the resulting unique log file
> >
> > 2. set a distinct environment variable for each host (using RewriteCond/RewriteRule) and use the optional log condition to determine to what file to log, i.e. have one CustomLog directive per host name.
> >
> > RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
> > RewriteCond ${vhost:%1} ^(.+)$
> > RewriteRule . - [E=%1:1]
> >
> > CustomLog /var/www/log/server1.log combined env=server1
> > CustomLog /var/www/log/server2.log combined env=server2
> > ...
> >
> > Not sure it will work, but maybe worth trying.
> >
> > -ascs
> >
> > -----Message d'origine-----
> > De : Terry [mailto:td3201@gmail.com]
> > Envoyé : vendredi 11 janvier 2008 16:25
> > À : users@httpd.apache.org
> > Objet : [users@httpd] splitting out to different files in customlog in mass vhost
> >
> >
> > Hello,
> >
> > My vhost config is at the bottom. Today, it is writing a special log format for all of my vhosts to a single file. I would like to separate them out into separate files based on my vhost.map or the
> > %{HOST}i or something similar. I tried CustomLog
> > logs/%{HOST}i-access_log but it appears to not honor that variable in
> > the CustomLog context. Any ideas? I can't do it on the backend
> > because I need my log files to be in common log format so the hostname isn't included in that format.
> >
> > Thanks!
> > Terry
> >
> >
> > <VirtualHost 10.0.1.37:80>
> > ServerAdmin hostmaster@foobar.com
> > ServerName omajelws04.foobar.com
> > Include conf/vhost_mass.conf
> > LogFormat "%{Host}i %h %l %u %t \"%r\" %s %b" vcommon
> > LogFormat "%h %l %u %t \"%r\" %>s %b" common
> > LogFormat "%{Host}i %h %l %u %t \"%r\" %>s %b \"%{Referer}i\"
> > \"%{User-agent}i\"" vcombined
> > CustomLog logs/shared_access_log vcombined
> > CustomLog logs/common_access_log common
> > RewriteEngine On
> > RewriteMap lowercase int:tolower
> > RewriteMap vhost txt:/etc/httpd/conf/vhost.map
> > RewriteCond %{REQUEST_URI} !^/icons/
> > RewriteCond %{REQUEST_URI} !^/cgi-bin/
> > RewriteCond ${lowercase:%{SERVER_NAME}} ^(?:www\.)?(.+)$
> > RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
> > RewriteCond ${vhost:%1} ^(/.*)$
> > RewriteRule ^/(.*)$ %1/$1
> > RewriteCond %{REQUEST_URI} ^/cgi-bin/
> > RewriteCond ${lowercase:%{SERVER_NAME}} ^(?:www\.)?(.+)$
> > RewriteRule ^/(.*)$ /home/%1/cgi-bin/$1 [T=application/x-httpd-cgi]
> > <Directory "/">
> > AllowOverride All
> > </Directory>
> > </VirtualHost>
> >
> > ---------------------------------------------------------------------
> > The official User-To-User support forum of the Apache HTTP Server Project.
> > See <URL:http://httpd.apache.org/userslist.html> for more info.
> > To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> > " from the digest: users-digest-unsubscribe@httpd.apache.org
> > For additional commands, e-mail: users-help@httpd.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > The official User-To-User support forum of the Apache HTTP Server Project.
> > See <URL:http://httpd.apache.org/userslist.html> for more info.
> > To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> > " from the digest: users-digest-unsubscribe@httpd.apache.org
> > For additional commands, e-mail: users-help@httpd.apache.org
> >
> >
>
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] splitting out to different files in customlog in mass vhost
Posted by Terry <td...@gmail.com>.
I can't include the host header in the log as it will break our stats
program which needs common log format. Here is what I have:
RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
RewriteCond ${vhost:%1} ^(.+)$
RewriteRule . - [E=%1:1]
LogFormat "%h %l %u %t \"%r\" %>s %b" common
CustomLog logs/foobar.com_access.log common env=foobar.com
If I go to foobar.com, it is not showing up in the logs. :\ I
think you are on the right track though.
On Jan 11, 2008 10:11 AM, Axel-Stephane SMORGRAV
<Ax...@europe.adp.com> wrote:
> I can basically see two ways of doing this:
>
> 1. Include the host header in the log and use a script to split the resulting unique log file
>
> 2. set a distinct environment variable for each host (using RewriteCond/RewriteRule) and use the optional log condition to determine to what file to log, i.e. have one CustomLog directive per host name.
>
> RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
> RewriteCond ${vhost:%1} ^(.+)$
> RewriteRule . - [E=%1:1]
>
> CustomLog /var/www/log/server1.log combined env=server1
> CustomLog /var/www/log/server2.log combined env=server2
> ...
>
> Not sure it will work, but maybe worth trying.
>
> -ascs
>
> -----Message d'origine-----
> De : Terry [mailto:td3201@gmail.com]
> Envoyé : vendredi 11 janvier 2008 16:25
> À : users@httpd.apache.org
> Objet : [users@httpd] splitting out to different files in customlog in mass vhost
>
>
> Hello,
>
> My vhost config is at the bottom. Today, it is writing a special log format for all of my vhosts to a single file. I would like to separate them out into separate files based on my vhost.map or the
> %{HOST}i or something similar. I tried CustomLog
> logs/%{HOST}i-access_log but it appears to not honor that variable in
> the CustomLog context. Any ideas? I can't do it on the backend
> because I need my log files to be in common log format so the hostname isn't included in that format.
>
> Thanks!
> Terry
>
>
> <VirtualHost 10.0.1.37:80>
> ServerAdmin hostmaster@foobar.com
> ServerName omajelws04.foobar.com
> Include conf/vhost_mass.conf
> LogFormat "%{Host}i %h %l %u %t \"%r\" %s %b" vcommon
> LogFormat "%h %l %u %t \"%r\" %>s %b" common
> LogFormat "%{Host}i %h %l %u %t \"%r\" %>s %b \"%{Referer}i\"
> \"%{User-agent}i\"" vcombined
> CustomLog logs/shared_access_log vcombined
> CustomLog logs/common_access_log common
> RewriteEngine On
> RewriteMap lowercase int:tolower
> RewriteMap vhost txt:/etc/httpd/conf/vhost.map
> RewriteCond %{REQUEST_URI} !^/icons/
> RewriteCond %{REQUEST_URI} !^/cgi-bin/
> RewriteCond ${lowercase:%{SERVER_NAME}} ^(?:www\.)?(.+)$
> RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
> RewriteCond ${vhost:%1} ^(/.*)$
> RewriteRule ^/(.*)$ %1/$1
> RewriteCond %{REQUEST_URI} ^/cgi-bin/
> RewriteCond ${lowercase:%{SERVER_NAME}} ^(?:www\.)?(.+)$
> RewriteRule ^/(.*)$ /home/%1/cgi-bin/$1 [T=application/x-httpd-cgi]
> <Directory "/">
> AllowOverride All
> </Directory>
> </VirtualHost>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
RE: [users@httpd] splitting out to different files in customlog in mass vhost
Posted by Axel-Stephane SMORGRAV <Ax...@europe.adp.com>.
I can basically see two ways of doing this:
1. Include the host header in the log and use a script to split the resulting unique log file
2. set a distinct environment variable for each host (using RewriteCond/RewriteRule) and use the optional log condition to determine to what file to log, i.e. have one CustomLog directive per host name.
RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
RewriteCond ${vhost:%1} ^(.+)$
RewriteRule . - [E=%1:1]
CustomLog /var/www/log/server1.log combined env=server1
CustomLog /var/www/log/server2.log combined env=server2
...
Not sure it will work, but maybe worth trying.
-ascs
-----Message d'origine-----
De : Terry [mailto:td3201@gmail.com]
Envoyé : vendredi 11 janvier 2008 16:25
À : users@httpd.apache.org
Objet : [users@httpd] splitting out to different files in customlog in mass vhost
Hello,
My vhost config is at the bottom. Today, it is writing a special log format for all of my vhosts to a single file. I would like to separate them out into separate files based on my vhost.map or the
%{HOST}i or something similar. I tried CustomLog
logs/%{HOST}i-access_log but it appears to not honor that variable in
the CustomLog context. Any ideas? I can't do it on the backend
because I need my log files to be in common log format so the hostname isn't included in that format.
Thanks!
Terry
<VirtualHost 10.0.1.37:80>
ServerAdmin hostmaster@foobar.com
ServerName omajelws04.foobar.com
Include conf/vhost_mass.conf
LogFormat "%{Host}i %h %l %u %t \"%r\" %s %b" vcommon
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Host}i %h %l %u %t \"%r\" %>s %b \"%{Referer}i\"
\"%{User-agent}i\"" vcombined
CustomLog logs/shared_access_log vcombined
CustomLog logs/common_access_log common
RewriteEngine On
RewriteMap lowercase int:tolower
RewriteMap vhost txt:/etc/httpd/conf/vhost.map
RewriteCond %{REQUEST_URI} !^/icons/
RewriteCond %{REQUEST_URI} !^/cgi-bin/
RewriteCond ${lowercase:%{SERVER_NAME}} ^(?:www\.)?(.+)$
RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
RewriteCond ${vhost:%1} ^(/.*)$
RewriteRule ^/(.*)$ %1/$1
RewriteCond %{REQUEST_URI} ^/cgi-bin/
RewriteCond ${lowercase:%{SERVER_NAME}} ^(?:www\.)?(.+)$
RewriteRule ^/(.*)$ /home/%1/cgi-bin/$1 [T=application/x-httpd-cgi]
<Directory "/">
AllowOverride All
</Directory>
</VirtualHost>
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org