-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Conversation
@@ -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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do, thanks vishr.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
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:log.Printf("%s %s %s %s %s %d", parseIP(remoteAddr), method, path, code, stop.Sub(start), size)
@@ -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.
… removed checking of headers for real ip address in event of reverse proxy
Closed #214 |
Addressing this feature: #112
Looking forward to hearing your thoughts.