Skip to content

Commit

Permalink
Add packages for factories
Browse files Browse the repository at this point in the history
Create new request-logging module
Address other PR comments
  • Loading branch information
ghenkes committed Jan 25, 2016
1 parent 75459bd commit 08de987
Show file tree
Hide file tree
Showing 41 changed files with 169 additions and 92 deletions.
36 changes: 16 additions & 20 deletions docs/source/manual/configuration.rst
Expand Up @@ -69,7 +69,7 @@ GZip
.. code-block:: yaml
server:
gzip:
gzip:
bufferSize: 8KiB
Expand Down Expand Up @@ -105,15 +105,13 @@ Request Log
.. code-block:: yaml
server:
requestLog:
- type: SLF4J
timeZone: UTC
requestLog:
timeZone: UTC
====================== ================ ===========
Name Default Description
====================== ================ ===========
type SLF4J The request log type. SLF4J or Logback-Access.
timeZone UTC The time zone to which request timestamps will be converted.
appenders console appender The set of AppenderFactory appenders to which requests will be logged.
*TODO* See logging/appender refs for more info
Expand Down Expand Up @@ -226,7 +224,7 @@ Name Default Description
applicationConnectors An `HTTP connector`_ A set of :ref:`connectors <man-configuration-connectors>` which will
listening on port 8080. handle application requests.
adminConnectors An `HTTP connector`_ An `HTTP connector`_ listening on port 8081.
listening on port 8081. A set of :ref:`connectors <man-configuration-connectors>` which will
listening on port 8081. A set of :ref:`connectors <man-configuration-connectors>` which will
handle admin requests.
adminMinThreads 1 The minimum number of threads to use for admin requests.
adminMaxThreads 64 The maximum number of threads to use for admin requests.
Expand All @@ -248,7 +246,7 @@ HTTP
----

.. code-block:: yaml
# Extending from the default server configuration
server:
applicationConnectors:
Expand Down Expand Up @@ -302,7 +300,7 @@ idleTimeout 30 seconds The maximum idle time for a connect
or when waiting for a new message to be sent on a connection.
This value is interpreted as the maximum time between some progress being made on the
connection. So if a single byte is read or written, then the timeout is reset.
minBufferPoolSize 64 bytes The minimum size of the buffer pool.
minBufferPoolSize 64 bytes The minimum size of the buffer pool.
bufferPoolIncrement 1KiB The increment by which the buffer pool should be increased.
maxBufferPoolSize 64KiB The maximum size of the buffer pool.
acceptorThreads # of CPUs/2 The number of worker threads dedicated to accepting connections.
Expand All @@ -329,7 +327,7 @@ HTTPS
Extends the attributes that are available to the :ref:`HTTP connector <man-configuration-http>`

.. code-block:: yaml
# Extending from the default server configuration
server:
applicationConnectors:
Expand All @@ -339,14 +337,14 @@ Extends the attributes that are available to the :ref:`HTTP connector <man-confi
keyStorePath: /path/to/file
keyStorePassword: changeit
keyStoreType: JKS
keyStoreProvider:
keyStoreProvider:
trustStorePath: /path/to/file
trustStorePassword: changeit
trustStoreType: JKS
trustStoreProvider:
trustStoreProvider:
keyManagerPassword: changeit
needClientAuth: false
wantClientAuth:
wantClientAuth:
certAlias: <alias>
crlPath: /path/to/file
enableCRLDP: false
Expand Down Expand Up @@ -397,8 +395,8 @@ excludedProtocols (none) A list of protocols (e.g.,
supportedCipherSuites (none) A list of cipher suites (e.g., ``TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256``) which
are supported. All other cipher suites will be refused
excludedCipherSuites (none) A list of cipher suites (e.g., ``TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256``) which
are excluded. These cipher suites will be refused and exclusion takes higher
precedence than inclusion, such that if a cipher suite is listed in
are excluded. These cipher suites will be refused and exclusion takes higher
precedence than inclusion, such that if a cipher suite is listed in
``supportedCipherSuites`` and ``excludedCipherSuites``, the cipher suite will be
excluded. To verify that the proper cipher suites are being whitelisted and
blacklisted, it is recommended to use the tool `sslyze`_.
Expand Down Expand Up @@ -552,7 +550,6 @@ Name Default Description
type REQUIRED The appender type. Must be ``console``.
threshold ALL The lowest level of events to print to the console.
timeZone UTC The time zone to which event timestamps will be converted.
Will be ignored if a logFormat is supplied.
target stdout The name of the standard stream to which events will be written.
Can be ``stdout`` or ``stderr``.
logFormat default The Logback pattern with which events will be formatted. See
Expand Down Expand Up @@ -591,11 +588,10 @@ threshold ALL The lowest level of events to write to
archive true Whether or not to archive old events in separate files.
archivedLogFilenamePattern (none) Required if ``archive`` is ``true``.
The filename pattern for archived files. ``%d`` is replaced with the date in ``yyyy-MM-dd`` form,
and the fact that it ends with ``.gz`` indicates the file will be gzipped as it's archived.
and the fact that it ends with ``.gz`` indicates the file will be gzipped as it's archived.
Likewise, filename patterns which end in ``.zip`` will be filled as they are archived.
archivedFileCount 5 The number of archived files to keep. Must be between ``1`` and ``50``.
timeZone UTC The time zone to which event timestamps will be converted.
Will be ignored if a logFormat is supplied.
logFormat default The Logback pattern with which events will be formatted. See
the Logback_ documentation for details.
============================ =========== ==================================================================================================
Expand Down Expand Up @@ -806,11 +802,11 @@ Name Default Description
====================== =============== ====================================================================================================
host localhost The hostname (or group) of the Ganglia server(s) to report to.
port 8649 The port of the Ganglia server(s) to report to.
mode unicast The UDP addressing mode to announce the metrics with. One of ``unicast``
mode unicast The UDP addressing mode to announce the metrics with. One of ``unicast``
or ``multicast``.
ttl 1 The time-to-live of the UDP packets for the announced metrics.
uuid (none) The UUID to tag announced metrics with.
spoof (none) The hostname and port to use instead of this nodes for the announced metrics.
spoof (none) The hostname and port to use instead of this nodes for the announced metrics.
In the format ``hostname:port``.
tmax 60 The tmax value to announce metrics with.
dmax 0 The dmax value to announce metrics with.
Expand Down Expand Up @@ -997,7 +993,7 @@ TLS
Name Default Description
=========================== ================= ============================================================================================================================
protocol TLSv1.2 The default protocol the client will attempt to use during the SSL Handshake.
See
See
`here <http://docs.oracle.com/javase/8/docs/technotes/guides/security/StandardNames.html#SSLContext>`_ for more information.
verifyHostname true Whether to verify the hostname of the server against the hostname presented in the server certificate.
keyStorePath (none) The path to the Java key store which contains the client certificate and private key.
Expand Down
5 changes: 5 additions & 0 deletions dropwizard-bom/pom.xml
Expand Up @@ -776,6 +776,11 @@
<artifactId>dropwizard-migrations</artifactId>
<version>${dropwizard.version}</version>
</dependency>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-request-logging</artifactId>
<version>${dropwizard.version}</version>
</dependency>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-servlets</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions dropwizard-core/pom.xml
Expand Up @@ -80,6 +80,10 @@
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-healthchecks</artifactId>
</dependency>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-request-logging</artifactId>
</dependency>
<dependency>
<groupId>net.sourceforge.argparse4j</groupId>
<artifactId>argparse4j</artifactId>
Expand Down
Expand Up @@ -23,10 +23,10 @@
import io.dropwizard.jetty.GzipHandlerFactory;
import io.dropwizard.jetty.MutableServletContextHandler;
import io.dropwizard.jetty.NonblockingServletHolder;
import io.dropwizard.jetty.RequestLogFactory;
import io.dropwizard.jetty.Slf4jRequestLogFactory;
import io.dropwizard.jetty.ServerPushFilterFactory;
import io.dropwizard.lifecycle.setup.LifecycleEnvironment;
import io.dropwizard.request.logging.LogbackAccessRequestLogFactory;
import io.dropwizard.request.logging.RequestLogFactory;
import io.dropwizard.servlets.ThreadNameFilter;
import io.dropwizard.util.Duration;
import io.dropwizard.validation.MinDuration;
Expand Down Expand Up @@ -209,7 +209,7 @@ public abstract class AbstractServerFactory implements ServerFactory {

@Valid
@NotNull
private RequestLogFactory requestLog = new Slf4jRequestLogFactory();
private RequestLogFactory requestLog = new LogbackAccessRequestLogFactory();

@Valid
@NotNull
Expand Down
@@ -1,2 +1 @@
io.dropwizard.jetty.ConnectorFactory
io.dropwizard.jetty.RequestLogFactory

This file was deleted.

4 changes: 0 additions & 4 deletions dropwizard-logging/pom.xml
Expand Up @@ -44,10 +44,6 @@
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-access</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
Expand Down
Expand Up @@ -10,6 +10,8 @@
import ch.qos.logback.core.spi.DeferredProcessingAware;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Strings;
import io.dropwizard.logging.async.AsyncAppenderFactory;
import io.dropwizard.logging.layout.LayoutFactory;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
Expand Down Expand Up @@ -84,26 +86,6 @@ public abstract class AbstractAppenderFactory<E extends DeferredProcessingAware>

private int discardingThreshold = -1;

@JsonProperty
public String getLogFormat() {
return logFormat;
}

@JsonProperty
public void setLogFormat(String logFormat) {
this.logFormat = logFormat;
}

@JsonProperty
public TimeZone getTimeZone() {
return timeZone;
}

@JsonProperty
public void setTimeZone(TimeZone timeZone) {
this.timeZone = timeZone;
}

private boolean includeCallerData = false;

@JsonProperty
Expand Down Expand Up @@ -136,6 +118,26 @@ public void setThreshold(Level threshold) {
this.threshold = threshold;
}

@JsonProperty
public String getLogFormat() {
return logFormat;
}

@JsonProperty
public void setLogFormat(String logFormat) {
this.logFormat = logFormat;
}

@JsonProperty
public TimeZone getTimeZone() {
return timeZone;
}

@JsonProperty
public void setTimeZone(TimeZone timeZone) {
this.timeZone = timeZone;
}

@JsonProperty
public boolean isIncludeCallerData() {
return includeCallerData;
Expand Down
Expand Up @@ -2,9 +2,12 @@

import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.core.Appender;
import ch.qos.logback.core.spi.DeferredProcessingAware;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import io.dropwizard.jackson.Discoverable;
import io.dropwizard.logging.async.AsyncAppenderFactory;
import io.dropwizard.logging.filter.FilterFactory;
import io.dropwizard.logging.layout.LayoutFactory;

/**
* A service provider interface for creating Logback {@link Appender} instances.
Expand All @@ -22,7 +25,7 @@
* @see SyslogAppenderFactory
*/
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
public interface AppenderFactory<E> extends Discoverable {
public interface AppenderFactory<E extends DeferredProcessingAware> extends Discoverable {
/**
* Given a Logback context, an application name, a layout,
* a thresholdFilterFactory, and an asyncAppenderFactory build a new appender.
Expand Down
Expand Up @@ -7,7 +7,9 @@
import ch.qos.logback.core.spi.DeferredProcessingAware;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
import io.dropwizard.logging.async.AsyncAppenderFactory;
import io.dropwizard.logging.filter.FilterFactory;
import io.dropwizard.logging.layout.LayoutFactory;

import javax.validation.constraints.NotNull;

Expand Down
Expand Up @@ -19,8 +19,12 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import io.dropwizard.jackson.Jackson;
import io.dropwizard.logging.async.AsyncAppenderFactory;
import io.dropwizard.logging.async.AsyncLoggingEventAppenderFactory;
import io.dropwizard.logging.filter.FilterFactory;
import io.dropwizard.logging.filter.ThresholdFilterFactory;
import io.dropwizard.logging.layout.DropwizardLayoutFactory;
import io.dropwizard.logging.layout.LayoutFactory;

import javax.management.InstanceAlreadyExistsException;
import javax.management.MalformedObjectNameException;
Expand Down
Expand Up @@ -15,7 +15,9 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
import io.dropwizard.logging.async.AsyncAppenderFactory;
import io.dropwizard.logging.filter.FilterFactory;
import io.dropwizard.logging.layout.LayoutFactory;
import io.dropwizard.util.Size;
import io.dropwizard.validation.ValidationMethod;

Expand Down
Expand Up @@ -7,7 +7,9 @@
import ch.qos.logback.core.net.SyslogConstants;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
import io.dropwizard.logging.async.AsyncAppenderFactory;
import io.dropwizard.logging.filter.FilterFactory;
import io.dropwizard.logging.layout.LayoutFactory;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
Expand Down
@@ -1,12 +1,13 @@
package io.dropwizard.logging;
package io.dropwizard.logging.async;

import ch.qos.logback.core.AsyncAppenderBase;
import ch.qos.logback.core.spi.DeferredProcessingAware;

/**
* Factory used to create an {@link AsyncAppenderBase} of type E
* @param <E> The type of log event
*/
public interface AsyncAppenderFactory<E> {
public interface AsyncAppenderFactory<E extends DeferredProcessingAware> {

/**
* Creates an {@link AsyncAppenderBase} of type E
Expand Down
@@ -1,4 +1,4 @@
package io.dropwizard.logging;
package io.dropwizard.logging.async;

import ch.qos.logback.classic.AsyncAppender;
import ch.qos.logback.classic.spi.ILoggingEvent;
Expand Down
Expand Up @@ -2,12 +2,13 @@

import ch.qos.logback.classic.Level;
import ch.qos.logback.core.filter.Filter;
import ch.qos.logback.core.spi.DeferredProcessingAware;

/**
* An interface for building Logback {@link Filter Filters}
* @param <E> The type of log event
*/
public interface FilterFactory<E> {
public interface FilterFactory<E extends DeferredProcessingAware> {

/**
* Creates a {@link Filter} of type E
Expand Down
Expand Up @@ -2,13 +2,14 @@

import ch.qos.logback.classic.Level;
import ch.qos.logback.core.filter.Filter;
import ch.qos.logback.core.spi.DeferredProcessingAware;
import ch.qos.logback.core.spi.FilterReply;

/**
* Factory for building a logback {@link Filter} that will always defer to the next Filter.
* @param <E> The type of log event
*/
public class NullFilterFactory<E> implements FilterFactory<E> {
public class NullFilterFactory<E extends DeferredProcessingAware> implements FilterFactory<E> {

/**
* Creates a {@link Filter} that will always defer to the next Filter in the chain, if any.
Expand Down
@@ -1,10 +1,11 @@
package io.dropwizard.logging;
package io.dropwizard.logging.layout;

import java.util.TimeZone;

import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.pattern.PatternLayoutBase;
import io.dropwizard.logging.DropwizardLayout;

/**
* Factory that creates a {@link DropwizardLayout}
Expand Down

0 comments on commit 08de987

Please sign in to comment.