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

Feature/378 request logging #379

Merged
merged 11 commits into from
Jan 25, 2018
Merged

Conversation

marcinczeczko
Copy link
Contributor

@marcinczeczko marcinczeczko commented Jan 23, 2018

Description

Added access logging capabilities to the Knotx HTTP Server. The feature uses the Vert.x logging handler so it brings a limited capabilities of the log message configuration, such as:

  • Enable/Disable access log
  • Logging after request arrives, or after response
  • Pick one of the available log formats - DEFAULT (as apache log), SHORT, TINY

Besides, a default logback configuration updated to add additional log appender for a access log.

Motivation and Context

The operation & maintenance of the Knot.x require the access log information to be able to monitor/trouble shoot the set up.
It partially fixes #378

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.

<logger name="io.vertx.ext.web.handler.impl.LoggerHandlerImpl" level="INFO" additivity="false">
<appender-ref ref="access"/>
</logger>

<logger name="io.knotx" level="INFO"
Copy link
Member

Choose a reason for hiding this comment

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

Can we add logger for io.vertx, io.reactivex ?

Copy link
Member

Choose a reason for hiding this comment

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

Let's do that for WARN level.

</encoder>
</appender>

<logger name="io.vertx.ext.web.handler.impl.LoggerHandlerImpl" level="INFO" additivity="false">
Copy link
Member

Choose a reason for hiding this comment

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

Please add some comment that it logs requests :)

| Name | Type | Mandatory | Description |
|-------:|:-------:|:-------: |-------|
| `enabled` | `boolean` | | Enable/Disable access log. Default is `true` |
| `immediate` | `boolean` | | Log before request or after. Default is `false` - log after request |
Copy link
Member

Choose a reason for hiding this comment

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

Maybe this property should be mode with values "before" and "after"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll keep it as it is now, as the same terminology is in the vertx access log handler used here.

|-------:|:-------:|:-------: |-------|
| `enabled` | `boolean` | | Enable/Disable access log. Default is `true` |
| `immediate` | `boolean` | | Log before request or after. Default is `false` - log after request |
| `format` | `String` | | Format of the access log. Allowed valueds are `DEFAULT`, `SHORT`, `TINY`. Default tries to log in a format similar to Apache log format, while the other 2 are more suited to development mode. Default format is `DEFAULT` |
Copy link
Member

Choose a reason for hiding this comment

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

Can you provide here any url to documentation defining Apache log format?
Maybe there should be a short note with link to #configure-access-log where those formats are explained?


public class AccessLogConfig {

public static final boolean DEFAULT_ENABLED = true;
Copy link
Member

Choose a reason for hiding this comment

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

I believe we can make those constants at least package private if not private.

@@ -38,6 +38,20 @@
</encoder>
</appender>

<appender name="access" class="ch.qos.logback.core.FileAppender">
Copy link
Member

Choose a reason for hiding this comment

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

Maybe it is also worth to update example in the same way as standalone (logging to file appender instead of STDOUT)?
Or maybe in the example everything should be logged int STDOUT?

<logger name="io.vertx.ext.web.handler.impl.LoggerHandlerImpl" level="INFO" additivity="false">
<appender-ref ref="access"/>
</logger>

<logger name="io.knotx" level="INFO"
Copy link
Member

Choose a reason for hiding this comment

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

Let's do that for WARN level.

@marcinczeczko
Copy link
Contributor Author

Please review once again. Improved logging capabilities to be more easier to configure. Created documentation page about how to configure logging.

private static final boolean DEFAULT_LOGGER_IMMEDIATE = false;
private static final String DEFAULT_LOGGER_FORMAT = LoggerFormat.DEFAULT.toString();

private boolean enabled;
Copy link
Member

Choose a reason for hiding this comment

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

Config properties can be final.

@marcinczeczko marcinczeczko merged commit dc865af into master Jan 25, 2018
@marcinczeczko marcinczeczko deleted the feature/378-request-logging branch January 25, 2018 12:33
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.

Incoming and outgoing request logging
4 participants