Message-ID: <30563168.485.1711695607066.JavaMail.serveradmin@t01app> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_484_32971496.1711695607062" ------=_Part_484_32971496.1711695607062 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html 4.2 Apache Log Management

4.2 Apache Log Management

This article can still be improved by adding a longer term larger soluti= on for multi-site hosting for the error logs and a logging rotation solutio= n if we are not using Ubuntu.

=20

Strategy

=20

By default Apache just keeps it main log files in /var/log/apache2/ as s= ingle files,access.log - all incoming requests and respons= es
error.log - any errors
other_vhosts_acc= ess.log - access log for VirtualHosts that don't define their own = logfile

=20

This is fine for casual servers. However, as you get more serious the fo= llowing will happen,

=20
    =20
  1. Traffic Increases - your single log files start becoming too big to loo= k through.
  2. =20
  3. It Gets Harder to Distinguish Sites - if you are hosting more than one = site, it becomes hard to distinguish what is what.
  4. =20
=20

To solve this we need to do log managaement focusing on two things,

= =20
    =20
  1. Enable automatic roll over of logs.
  2. =20
  3. Split the log files by virtual hosts.
  4. =20
=20

Ubuntu and Apache

= =20

If you use apt-get to install Apache on Ubuntu log management is already= happening by default. This is done by logrotat= e. Settings can be found in /etc/logrotate.d/apache2 and the defaults a= re,

=20 =20

If someone looks up size x please share it here.

=20

Dist= inguishing Between Virtual Hosts

=20

The ubuntu logrotate is great but what about distinguishing between diff= erent virtual hosts.

=20

There are two approaches I am aware of and I personally only have figure= d out approach 1 where each virtual host has its own set of log files which= I call "Virtual Host Based Logging". Further information is at the Apache2 Log Files documentation.

=20
    =20
  1. Virtual Host Based Logging=20
      =20
    1. Pro - Simple to understand. You use a packaged Apache program to rotate= the logs.
    2. =20
    3. Pro - If you drop these files into the /etc/logrotate.d/apache2 with .l= og extensions they automatically rotate (provided you are using Ubuntu).=20
    4. Con - Not feasible when you have too many (how many is this?) as you ru= n out of file descriptors.
    5. =20
  2. =20
  3. Use a single file and split among virtual hosts.=20
      =20
    1. You use an external program to both rotate and split the logs.
    2. =20
    3. Con - The technique used for access.log is not available for the error = log (to reference why here) so is it reallly that good?
    4. =20
  4. =20
=20

Virtual Host B= ased Logging

=20

This approach is already outlined as part of my Apache Setu= p article.

=20

= Split and Rotate Logs with External Program

=20

Contenders

=20

There does not seem to be a clear winner in this department. Here is wha= t I looked at that appear to be popular via Google searches.

=20

logroate - use what Ubuntu uses. Some possible references,

=20

http://blog.andre= wbeacock.com/2008/02/how-to-use-logrotate-with-apaches.html - talks abo= ut using logrotate with Tomcat without requiring a restart to rollover log = file.

=20

Vlogger - Similar (and intended as a replacement for) = cronolog or httplog. This looks really easy to use, creates sy= mlinks and can can hook into a database. On the negative side, the package = seemed last updated in 2005.
Cronolog - the recommended solution fro= m the Apache2 Log Files documentation but it was l= ast updated in 2002. The biggest negative, I could not in 5 minutes and nev= er bothered to go further on figuring out how to pipe for rollover = and how to split at the same time. The problem is that during roll= over, the cronolog actually stops logging for a short time before writing = to a new file.

=20

References

=20
    =20
  1. Apache Log Files documenation
  2. =20
  3. Webmin
  4. =20
  5. ...
  6. =20
------=_Part_484_32971496.1711695607062--