Forum: NGINX How to make the log file printed by access_log split

2974d09ac2541e892966b762aad84943?d=identicon&s=25 shawnxzhou (Guest)
on 2013-07-25 10:53
(Received via mailing list)
what's the limit of the size of log file, and what will happen when it
reaches the limitation?
if I want to split the log file by timeline, say start a new file on the
beginning of an hour, how can I configure ngnix?

thanks

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,241226,241226#msg-241226
A8108a0961c6087c43cda32c8616dcba?d=identicon&s=25 Maxim Dounin (Guest)
on 2013-07-25 11:29
(Received via mailing list)
Hello!

On Thu, Jul 25, 2013 at 04:52:38AM -0400, shawnxzhou wrote:

> what's the limit of the size of log file, and what will happen when it
> reaches the limitation?
> if I want to split the log file by timeline, say start a new file on the
> beginning of an hour, how can I configure ngnix?

This isn't something nginx is expected to do.  Instead, this is
what your favorite log rotation program does, and then uses USR1
signal to instruct nginx to reopen log files, see [1].  Consult
your OS documentation for more details, usually "man newsyslog" or
"man logrotate" helps.

[1] http://nginx.org/en/docs/control.html#logs

--
Maxim Dounin
http://nginx.org/en/donation.html
24a9986d5a2fa4d006f22abed0b8951e?d=identicon&s=25 Richard Kearsley (Guest)
on 2013-07-25 11:40
(Received via mailing list)
Hi
There's no size limit, it will keep getting bigger until your disk is
full
Here's a script I use to rotate the log, run it from cron every hour
hope it helps

#!/bin/sh
PID=`cat /usr/local/nginx/logs/nginx.pid`
LOG="/usr/local/nginx/logs/access.log"
NOW=$(date +"%Y-%m-%d-%H-%M")
NEWLOG="${LOG}.${NOW}
mv ${LOG} ${NEWLOG}
kill -USR1 ${PID}
gzip ${NEWLOG}
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.