Forum OpenACS Q&A: Compressing nslog access log's...

Collapse
Posted by Marc Fournier on
Hi All,

Quick question is there a way to configure AOLServer/OpenACS to gzip
the access log files? The problem I'm running into is some very large
access logs that I want to compress and archive, but at the same time
I want to not have to worry that OpenACS can not pick up that a log
has been gzip'd... currently I end up with.

access.log.000
access.log.000.gz
access.log.001
access.log.001.gz

of which the gz/non-gz'd files are completely different files, not the
same ones compressed... This is what I'd like to avoid..

Collapse
Posted by Jonathan Ellis on
I think you'd have to write your own logging proc. Should be a simple enough proc to write:
* incr count on .gz files in log dir
* ns_logroll
* gzip access.log.000
then schedule your proc manually rather than using the log module.
Collapse
Posted by Michael A. Cleverly on
I imagine you may have already implemented your own proc to roll your access log as Jonathan suggested. On the off chance you haven't or for the benefit of some future searcher, here is a proc that I used to use under AOLserver 2.3 (had it scheduled via ns_schedule_daily to run at 00:00). I don't use it anymore because I finally realized I never looked or did anything with the logs, so why did I need to keep them? 😉

proc roll_access_log {} {
    set today [ns_time]
    set yesterday [expr [ns_time] - 86400]
    set yesterday [ns_fmttime $yesterday "%Y-%m-%d"]
    set log_dir servers/store/modules/nslog

    ns_log notice "Preparing to roll access log..."
    ns_accesslog roll $log_dir/access.log.$yesterday
    exec gzip -9 $log_dir/access.log.$yesterday

    ns_log notice "Access log rolled..."
}