Skip to content

Adding IP Addresses in log entries #212

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

Closed
wants to merge 4 commits into from

Conversation

husobee
Copy link
Contributor

@husobee husobee commented Sep 17, 2015

Addressing this feature: #112

Looking forward to hearing your thoughts.

@@ -34,7 +64,7 @@ func Logger() echo.MiddlewareFunc {
code = color.Cyan(n)
}

log.Printf("%s %s %s %s %d", method, path, code, stop.Sub(start), size)
log.Printf("%s %s %s %s %s %d", parseIP(remoteAddr), method, path, code, stop.Sub(start), size)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we just display what's coming in the request?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, we could, lots of times I find myself proxy-ing from another web server (nginx, apache), or a load balancer, and sometimes using headers can be helpful in those cases. Otherwise it will look like the request is coming from the proxy host or load balancer instead of who it is really coming from.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, this logger, and the other core middleware (except maybe compression) aren't necessarily meant to be used for every production situation. The logs it produces don't contain several values that might be needed by some users. It should be kept as simple as possible.

@husobee, out of curiosity, why not use net.SplitHostPort

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand, getting real IP should be the case. As @axdg mentioned, we should be using net.SplitHostPort.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @axdg, there could many possible values to put in the logs. In future we should be capable of specifying the format (with fields) for logger (low priority).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am okay with the proxy headers, that's how it should be, I was more specific about calling net.ParseIP do we really need it, it's just a logger? We should just get the IP, split and display. What do you guys think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@husobee I think, you should bring back the header logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do, thanks vishr.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Header is fine, it obviously useful if your running behind a proxy. But as it stands, the values that are being logged would appear to have been chosen arbitrarily. At some point it’ll need a refactor, as vishr said.

P.S. do you guys have some time to discuss #205 in gitter?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am outside, you guys can discuss send me the transcript.

Sent from my iPhone

On Sep 18, 2015, at 7:54 AM, axdg notifications@github.com wrote:

In middleware/logger.go:

@@ -34,7 +64,7 @@ func Logger() echo.MiddlewareFunc {
code = color.Cyan(n)
}

  •       log.Printf("%s %s %s %s %d", method, path, code, stop.Sub(start), size)
    
  •       log.Printf("%s %s %s %s %s %d", parseIP(remoteAddr), method, path, code, stop.Sub(start), size)
    
    Header is fine, it obviously useful if your running behind a proxy. But as it stands, the values that are being logged would appear to have been chosen arbitrarily. At some point it’ll need a refactor, as vishr said. P.S. do you guys have some time to discuss RFC 2616 10.4.6 Compliance - Method Not Allowed On Resources Method isn't Specified #205 in glitter? On 19 September 2015 at 12:50:50 am, husobee (notifications@github.com) wrote: In middleware/logger.go:
    @@ -34,7 +64,7 @@ func Logger() echo.MiddlewareFunc { code = color.Cyan(n) } - log.Printf("%s %s %s %s %d", method, path, code, stop.Sub(start), size) + log.Printf("%s %s %s %s %s %d", parseIP(remoteAddr), method, path, code, stop.Sub(start), size)
    will do, thanks vishr. — Reply to this email directly or view it on GitHub.

    Reply to this email directly or view it on GitHub.

Ben Huson added 3 commits September 18, 2015 10:51
… removed checking of headers for real ip address in event of reverse proxy
@vishr vishr self-assigned this Sep 18, 2015
@vishr
Copy link
Member

vishr commented Sep 18, 2015

Closed #214

@vishr vishr closed this Sep 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants