Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: log-rotate can not rotate logs strictly hourly(or minutely) #6517

Closed
snowdusk opened this issue Mar 5, 2022 · 6 comments · Fixed by #6521
Closed

bug: log-rotate can not rotate logs strictly hourly(or minutely) #6517

snowdusk opened this issue Mar 5, 2022 · 6 comments · Fixed by #6521
Labels
bug Something isn't working

Comments

@snowdusk
Copy link
Contributor

snowdusk commented Mar 5, 2022

Issue description

e.g.
Apisix start time is 15:29:23, log-rotate interval is 3600(1 hour)
Next rotate time is 16:29:23, next next rotate time is 17:29:23

I want next rotate time is 16:00:00, next next rotate time is 17:00:00

The current implement:

    if not rotate_time then
        -- first init rotate time
        rotate_time = now_time + interval
        core.log.info("first init rotate time is: ", rotate_time)
        return
    end

This is my change.

    if not rotate_time then
        -- first init rotate time
        rotate_time = now_time + interval - (now_time % interval)
        core.log.info("first init rotate time is: ", rotate_time)
        return
    end
@snowdusk snowdusk changed the title feat: log-rotate最好可以整点切割 feat: As a User, I want log-rotate can rotate logs strictly hourly(or minutely) Mar 5, 2022
@snowdusk snowdusk changed the title feat: As a User, I want log-rotate can rotate logs strictly hourly(or minutely) bug: log-rotate can not rotate logs strictly hourly(or minutely) Mar 5, 2022
@shuaijinchao
Copy link
Member

What problem does this solve? Also I don't think this is a bug

@membphis
Copy link
Member

membphis commented Mar 6, 2022

@snowdusk I think you are right. It seems 139c397 break this feature

@membphis
Copy link
Member

membphis commented Mar 6, 2022

@snowdusk I think you are right. It seems 139c397 break this feature

need @shuaijinchao's help

@membphis membphis added bug Something isn't working and removed discuss labels Mar 6, 2022
@soulbird
Copy link
Contributor

soulbird commented Mar 6, 2022

Strictly hourly rotation of logs is better

@shuaijinchao
Copy link
Member

shuaijinchao commented Mar 6, 2022

@snowdusk Sorry, this is a problem caused by one of my previous PRs. Aligning time avoids fragmented logs in case of restarts etc. during rotation time, so the solution you provided would be better.

Are you interested in fixing it?

@snowdusk
Copy link
Contributor Author

snowdusk commented Mar 7, 2022

@shuaijinchao OK. I will create a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
4 participants