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

Logging with full QueryString #1017

Closed
andr33z opened this issue May 30, 2018 · 2 comments
Closed

Logging with full QueryString #1017

andr33z opened this issue May 30, 2018 · 2 comments
Labels
good first issue A user wrote a good first issue with clear instructions 🚀 status:implemented

Comments

@andr33z
Copy link

andr33z commented May 30, 2018

Examples for the Iris project can be found at
https://github.com/kataras/iris/tree/master/_examples.

Documentation for the Iris project can be found at
https://godoc.org/github.com/kataras/iris.

Love iris? Please consider supporting the project:
👉 https://iris-go.com/donate

Care to be part of a larger community? Fill our user experience form:
👉 https://goo.gl/forms/lnRbVgA6ICTkPyk02

====================================

❓ How to put full query string into custom log file?
i have following this reference to put custom file.
then i try to fire with this format :
http://localhost:9092/user/profile?name=andre&token=123123

then i check to my log file, it is not showing full request.
screen shot 2018-05-30 at 22 13 57

can anyone help me?
thank you

@kataras
Copy link
Owner

kataras commented May 30, 2018

Iris' request logger can communicate with the handlers to build and print a custom Message:

        logQueryMiddleware := func(ctx iris.Context) {
	    ctx.Values().Set("URL Query", ctx.Request().URL.Query().Encode())
	    ctx.Next()
        }

	loggerConfig := logger.Config{
                // ...
		MessageContextKeys: []string{"URL Query"}, // <-- here
	}

        loggerMiddleware := logger.New(loggerConfig )

         app.Use(logQueryMiddleware, loggerMiddleware)

Although I've just pushed a commit to display the full url including the URL query if logger.Config{ Query: true } was passed as true. Example at: https://github.com/kataras/iris/blob/master/_examples/http_request/request-logger/main.go#L21

Upgrade with go get -u github.com/kataras/iris

Star the github repository and stay tuned @andr33z !

kataras added a commit that referenced this issue May 30, 2018
… bool`, if true prints the full path, including the URL query as requested at #1017
@kataras kataras added 🚀 status:implemented good first issue A user wrote a good first issue with clear instructions labels May 30, 2018
@andr33z
Copy link
Author

andr33z commented May 31, 2018

BEST! Thank you

@andr33z andr33z closed this as completed May 31, 2018
github-actions bot pushed a commit to goproxies/github.com-kataras-iris that referenced this issue Jul 27, 2020
… bool`, if true prints the full path, including the URL query as requested at kataras#1017

Former-commit-id: 03c8fc523a8ba955dae43e4c7e9498fc3d86a1c8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue A user wrote a good first issue with clear instructions 🚀 status:implemented
Projects
None yet
Development

No branches or pull requests

2 participants