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

LOG: Support log rotate? #759

Closed
mailbaoer opened this issue Sep 20, 2017 · 7 comments
Closed

LOG: Support log rotate? #759

mailbaoer opened this issue Sep 20, 2017 · 7 comments

Comments

@mailbaoer
Copy link

mailbaoer commented Sep 20, 2017

I use log from example file-logger , but it doesn't say how to rotate the log.
Then I use before hook to check log file name and set log output every query, is that right way?

// before all routers need to set default lang
func before(ctx iris.Context) {
	lang := ctx.Params().Get("lang")

	app := iris.New()
	f := newLogFile()
	defer f.Close()
	app.Logger().SetOutput(newLogFile())

	ctx.Next() // execute the next handler, in this case the main one.
}
@kataras
Copy link
Owner

kataras commented Oct 1, 2017

Hello @mailbaoer, First; do you try to change the application's logger inside a handler? This is not right why you do something like this? Secondly, I don't understand your question, could you please re-form with an example output? what do you expect to see and what you see instead?

@mailbaoer
Copy link
Author

mailbaoer commented Oct 9, 2017

@kataras sorry for late! I have a long holidays, so did not see it! Waht I want to do is cut log into pieces, like nginx one day one piece or one hour one piece, how can I do this?

@speedwheel
Copy link
Contributor

@mailbaoer there is an example over here that shows you how to make daily logs, you can adapt that example to make different intervals of time:

https://github.com/kataras/iris/blob/master/_examples/http_request/request-logger/request-logger-file/main.go

@mailbaoer
Copy link
Author

@speedwheel thank you very much! I will try it later!:thumbsup:

@speedwheel
Copy link
Contributor

speedwheel commented Oct 10, 2017

@mailbaoer You're welcome!

@zuoRambo
Copy link

I feel log rotate is one import feature that we should support! @speedwheel ,as the example code, we should stop our application every day.

@kataras
Copy link
Owner

kataras commented Dec 19, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants