On Fri, 22 Jan 2010 14:59:24 +0530, "J. Bakshi" <joyd...@infoservices.in>
wrote:
> [1]  I am running a development server with multiple vhosts. Presently
> all logs can be seen at  /etc/apache2/log/error.log  and at
> /etc/apache2/log/access.log. How can I break the logs for each and every
> vhosts ; so that the log only contains the specific vhost information ?
> [2]  How can I set webalizer for each and every vhosts ?


Here is my solution, I hope it could help you out : 



Apache side
  # cat /etc/apache2/sites-available/intranet
    <VirtualHost *>
        ServerName intranet
        [...]
        ErrorLog /var/log/apache2/intranet_error.log
        CustomLog /var/log/apache2/intranet_access.log "combined"
        LogLevel error
        ScriptAlias /awstats/ "/usr/lib/cgi-bin/"
        [...]
    </VirtualHost> 
    
  # cat /etc/apache2/sites-available/web2
    <VirtualHost *>
          ServerName web2
          [...]
          ErrorLog /var/log/apache2/web2_error.log
          CustomLog /var/log/apache2/web2_access.log "combined"
          LogLevel error
          ScriptAlias /awstats/ "/usr/lib/cgi-bin/"
          [...]
    </VirtualHost>

    
Awstats side (similar to webstats)
  # cat /etc/awstats/awstats.intranet.conf
  [...]
  SiteDomain="intranet"
  [...]
  LogFile="/var/log/apache2/intranet_access.log"
  [...]

  # cat /etc/awstats/awstats.web2.conf
  [...]
  SiteDomain="web2"
  [...]
  LogFile="/var/log/apache2/web2_access.log"
  [...]
  
  
And then, I use logrotate to rotate apache logs : I use the prerotate
command to update awstats stats before truncate logs : 
  # cat /etc/logrotate.d/apache2
  /var/log/apache2/*.log {
          missingok
          rotate 31
          compress
          nodelaycompress
          notifempty
          create 644 root adm
          sharedscripts
          postrotate
          if [ -f /var/run/apache2.pid ]; then
          /etc/init.d/apache2 restart > /dev/null
          fi
          endscript
          prerotate
           /opt/My_ Admin_Scripts/pre-logrotate_apache.sh     # <--- this
line is important
          endscript
          daily
          mailfirst
  }

  cat /usr/latecoere/pre-logrotate_apache.sh
  #!/bin/bash
  /usr/lib/cgi-bin/awstats.pl -update -config=intranet
-configdir=/etc/awstats
  /usr/lib/cgi-bin/awstats.pl -update -config=web2 -configdir=/etc/awstats


  Results are available at
http://server.fqdn/awstats/awstats.pl?config=intranet or
http://web2/awstats/awstats.pl?config=web2, etc....
  

---------------------------------------------------------------------
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-unsubscr...@httpd.apache.org
   "   from the digest: users-digest-unsubscr...@httpd.apache.org
For additional commands, e-mail: users-h...@httpd.apache.org

Reply via email to