For support nginx rotating log, these are some ways to solve this as the following:
- Using logrotate
- Using access_log pipe patched by tengine
But I'm more prefer to using variable in access_log for nginx just like this as the following:
http {
access_log logs/access-%YY-%MM-%DD-%HH-%mm-%ss.log
}
In nginx internals, there are no such variable like %YY, So i adding the variable by nginx module for nginx as the following:
- $datetime_year: [1970-xxxx]
- $datetime_month: [00-12]
- $datetime_day: [0-31]
- $datetime_hour: [0-23]
- $datetime_minute: [0-59]
- $datetime_second: [0-59]
- $datetime_lyear: localtime for datetime_year
- $datetime_lmonth: localtime for datetime_month
- $datetime_lday: localtime for datetime_day
- $datime_lhour: localtime for datetime_hour
- $datetime_lminute: localtime for datetime_minute
- $datetime_lsecond: localtime for datetime_second