13.06.2015 Views

Introduction to the Apache Web Server - ApacheCon

Introduction to the Apache Web Server - ApacheCon

Introduction to the Apache Web Server - ApacheCon

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

16.9.2 rotatelogs<br />

Cus<strong>to</strong>mLog "|/usr/local/apache/bin/rotatelogs /some/where 86400" common<br />

Implemented as a piped log file, which rotates your logs au<strong>to</strong>matically every day.<br />

The /some/where is where you want it <strong>to</strong> put <strong>the</strong> old log files each day. Specifically, it will create files called<br />

/some/shere.XXXXXXX, where XXXXXXX is <strong>the</strong> time in Unix time - that is, <strong>the</strong> number of seconds since Jan<br />

1, 1970. This number can be converted back in<strong>to</strong> human-readable time by <strong>the</strong> command:<br />

perl -le ’print scalar localtime($time);’<br />

where $time is <strong>the</strong> number appended <strong>to</strong> <strong>the</strong> end of <strong>the</strong> file name.<br />

The 86400 is <strong>the</strong> number of seconds in a day, and means that <strong>the</strong> log rotation will happen once a day. You<br />

may want <strong>to</strong> set this at 300 seconds (ever 5 minutes) <strong>to</strong> see what this does.<br />

NEED TO ADD 2.0 STUFF HERE<br />

16.9.3 logresolve<br />

cp ../logs/access_log ./<br />

./logresolve -s stats < access_log > resolved.log<br />

Resolves IP addresses, generates simple statistics.<br />

16.10 Logging for multiple virtual hosts<br />

• Each vhost should have its own log file<br />

• Alternately, if you have only one log file, make sure you use <strong>the</strong> extended (combined) log file format<br />

which contains <strong>the</strong> vhost name:<br />

"%v %h %l %u %t \"%r\" %>s %b"<br />

Note that this is <strong>the</strong> canonical name for <strong>the</strong> vhost, not necessarily <strong>the</strong> name with which <strong>the</strong> host was<br />

accessed. ie, could be www.apacheadmin.com ra<strong>the</strong>r than apacheadmin.com even if that’s what was<br />

actually used.<br />

104

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!