Best way for NGINX logs rotation
Best way for NGINX logs rotation
I wanted rotate access logs every minute without HUP signal or reopen utility.
Why? Because, i wanted fluently write into logs and logs must contain access
for 1 minute. I didn’t want call reopen utility and then move file, because i moved
files from quick (heap) storage to slow storage.
Finally i did patch which you can find in tools section.
Installation:
1, download patch
2, download nginx 0.8.53
3, extract nginx and go to the src dir
4, call patch: patch -p0 -i <path_to_dir_where_is_patch>/bbcdnTime0.8.53.patch
5, set in your nginx.conf something like this (keyword is $date_bbcdn) :
access_log /logdir/access_$date_bbcdn.access.log log;
and then you can see access logs in following format:
access_1293111000.access.log
And now you have new log every minute without any rotation script.
Categories:
Tags: