I have been trying for a while to figure out how to get individual log files for my virtual hosts. All the configurations I try. Apache fails to load until I go back and remove what I tried. Can someone tell me which files I need to edit and please provide working examples? I don't know what I am doing wrong, but I am still new at this. Thank for any help you can give.
Post your <virtualhost> container along with whatever you tried to add. If apache fails to load there's probably a syntax error or erroneous path in your addition.
Here is My mod_log_config.conf # # The following directives define some format nicknames for use with # a CustomLog directive. # # http://httpd.apache.org/docs-2.2/mod/mod_log_config.html # # # Format string: Nickname: # LogFormat "%h %l %u %t \"%r\" %>s %b" common LogFormat "%v %h %l %u %t \"%r\" %>s %b" vhost_common LogFormat "%{Referer}i -> %U" referer LogFormat "%{User-agent}i" agent LogFormat "%h %l %u %t \"%r\" %>s %b \ \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%v %h %l %u %t \"%r\" %>s %b \ \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined # To use %I and %O, you need to enable mod_logio <IfModule mod_logio.c> LogFormat "%h %l %u %t \"%r\" %>s %b \ \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio </IfModule> # Use one of these when you want a compact non-error SSL logfile on a virtual # host basis: <IfModule mod_ssl.c> Logformat "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \ \"%r\" %b" ssl_common Logformat "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \ \"%r\" %b \"%{Referer}i\" \"%{User-Agent}i\"" ssl_combined </IfModule> Here is my vhost.conf # # VirtualHost template: # Almost any Apache directive may go into a VirtualHost container. # The first VirtualHost section is used for requests without a known # server name. # ServerName linux2.networks.com NameVirtualHost * #I tried this CustomLog logs/referer "%{referer}i" <VirtualHost *> DocumentRoot /home/username/public_html/socom ServerName socom.networks.com ServerAlias *.socom.networks.com TransferLog logs/vhost_access_log #And I tried this. together and by themself </VirtualHost> <VirtualHost *> DocumentRoot /home/username/public_html/test ServerName linux2.networks.com </VirtualHost> Hope this help you figure out what I need to modify.
CustomLog needs to be inside the <VirtualHost> container it applies to. Not sure if you had it that way or not. It looks like you stuck a little too closely to the Apache manual when defining your logfile path. Try pointing the path to a directory you have access too, but is not in the public_html folder. You may even have some sort of "logs" directory in there with a log rotation daemon watching it already. Considering it appears you're trying to log referers, I'm guessing you might not want automatic log rotation anyways. Where you have TransferLog logs/vhost_access_log Code (markup): Use this, or a variation pointing somewhere you have access too, instead. CustomLog /home/username/logs/socom.referer.log referer Code (markup):
Ok that is working Thanks, I am new so I followed the documentation I just wish they would give examples. If they did it would make it easier for people starting out to figure out how to setup the server. I have two more questions: What is the difference between CustomLog common, referer, and combined or other log formats. The second is how would I setup log rotation of my access logs? Thanks for your help
The differences are what type of information is collected. This should tell you everything you need to know on that subject. http://httpd.apache.org/docs/2.2/mod/mod_log_config.html#formats Here's some documentation on log rotation. http://httpd.apache.org/docs/2.2/logs.html#rotation