Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm hoping to get some direction on how to set up truncating and gzip'ing on my domains' access logs. I notice that the core nginx access logs get split and compressed by default, yet my individual access logs continue to grow.

Is this something that can be set up and is handled by nginx or something else on my system that is managing it's core logs?

share|improve this question
    
Use logrotate? –  Michael Hampton Sep 13 '12 at 15:34

1 Answer 1

up vote 7 down vote accepted

/etc/logrotate.d/nginx

/var/log/nginx/access_log {
    rotate 7
    size 5k
    dateext
    dateformat -%Y-%m-%d
    missingok
    compress
    sharedscripts
    postrotate
        test -r /var/run/nginx.pid && kill -USR1 `cat /var/run/nginx.pid`
    endscript
}
share|improve this answer
    
Awesome. Logrotate was new to me. Makes perfect sense now. Thanks! –  Rob Sep 13 '12 at 15:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.