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

Response code logging tweaks - different log levels for success, redi… #427

Merged

Conversation

scypio
Copy link
Contributor

@scypio scypio commented Jun 29, 2018

…rect and error responses

Currently every response from repository that return HTTP status code different than 200 is logged using ERROR logger level. The strategy has been adjusted.

Description

2xx - success - log at debug
3xx - redirect - log at info
4xx - client error - log at warn
5xx - server error - log at error
other - log at warn

#423

Motivation and Context

Too many error messages may trigger unwanted warnings for devops. Error log level should indicate that something is wrong.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

I hereby agree to the terms of the Knot.x Contributor License Agreement.

@malaskowski
Copy link
Member

Thank you @scypio for this fix.

@@ -144,12 +145,21 @@ private String encode(String value) {
}

private ClientResponse toResponse(Buffer buffer, final HttpClientResponse httpResponse) {
if (httpResponse.statusCode() >= 300 && httpResponse.statusCode() < 400) { //redirect responses
LOGGER.info("Repository 3xx response: {}, Headers[{}]", httpResponse.statusCode(),
if (HttpStatusClass.SUCCESS.contains(httpResponse.statusCode())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

For a better readability of each condition, get the .statusCode() into variable and do the check against that variable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

scypio added 2 commits July 2, 2018 13:41
HTTP status code logging tweaks - PR changes
Http status logging tweaks  - typo fixed
@mateuszgrab-cognifide
Copy link

mateuszgrab-cognifide commented Jul 2, 2018

Would it be possible to add information about requested resource while logging response?
The issue I have is that it makes no sense in some cases to log every request, however it is good to know what resource was requested if there was >= 400 response code.

@malaskowski
Copy link
Member

What do you think about adding request path (especially in warn and error level) in the message?
I think that might be useful.

@scypio
Copy link
Contributor Author

scypio commented Jul 2, 2018

@Skejven @mateuszgrab-cognifide I added request URL logging for 4xx, 5xx response codes

@malaskowski malaskowski merged commit 372ab5d into Knotx:master Jul 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants