scm-spain / karyon2-accesslog

0 stars 1 forks source link

Karyon Access Log Interceptor Module

Build Status

Maven Central

This module add an Interceptor to Karyon so that log all requests.

How to use

First of all, add to your build.gradle the dependency as usually do, for example:

dependencies {
  ...
  compile 'com.scmspain.karyon:karyon2-accesslog:x.x.x'
}

Remember to check the maven central badge to get the latest version.

Then include AccessLogModule in your AppServer as follows:

...
@Modules(
    include = {
        ...
        AccessLogModule.class
    })
public interface AppServer {
  ...
}

And finally intercept all urls:

@Override
protected void configureServer() {
  ...
  interceptorSupport().forUri("/*").intercept(AccessLogInterceptor.class);
}

Log Formatter

By default CombinedApacheLog format is bind, but you can override this in your module as follows:

@Override
protected void configure() {
  ...
  binder.bind(AccessLogFormatter.class).to(JsonLog.class);
}

Available formatter classes: