All Projects → palantir → dropwizard-web-logger

palantir / dropwizard-web-logger

Licence: Apache-2.0 license
WebLoggerBundle is a Dropwizard bundle used to help log web activity to log files on a server’s backend

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to dropwizard-web-logger

gradle-docker-test-runner
Gradle plugin for running tests in Docker environments
Stars: ✭ 20 (+42.86%)
Mutual labels:  octo-correct-managed
palantir-java-format
A modern, lambda-friendly, 120 character Java formatter.
Stars: ✭ 203 (+1350%)
Mutual labels:  octo-correct-managed
go-baseapp
A lightweight starting point for Go web servers
Stars: ✭ 61 (+335.71%)
Mutual labels:  octo-correct-managed
Blueprint
A React-based UI toolkit for the web
Stars: ✭ 18,376 (+131157.14%)
Mutual labels:  octo-correct-managed
amalgomate
Go tool for combining multiple different main packages into a single program or library
Stars: ✭ 19 (+35.71%)
Mutual labels:  octo-correct-managed
phishcatch
A browser extension and API server for detecting corporate password use on external websites
Stars: ✭ 75 (+435.71%)
Mutual labels:  octo-correct-managed
log4j-sniffer
A tool that scans archives to check for vulnerable log4j versions
Stars: ✭ 180 (+1185.71%)
Mutual labels:  octo-correct-managed
python-jsonrpc-server
A Python 2 and 3 asynchronous JSON RPC server
Stars: ✭ 73 (+421.43%)
Mutual labels:  octo-correct-managed
conjure-rust
Conjure support for Rust
Stars: ✭ 14 (+0%)
Mutual labels:  octo-correct-managed
witchcraft-go-server
A highly opinionated Go embedded application server for RESTy APIs
Stars: ✭ 47 (+235.71%)
Mutual labels:  octo-correct-managed
Tslint
🚦 An extensible linter for the TypeScript language
Stars: ✭ 5,922 (+42200%)
Mutual labels:  octo-correct-managed
rust-zipkin
A library for logging and propagating Zipkin trace information in Rust
Stars: ✭ 50 (+257.14%)
Mutual labels:  octo-correct-managed
asana mailer
A script that uses Asana's RESTful API to generate plaintext and HTML emails.
Stars: ✭ 12 (-14.29%)
Mutual labels:  octo-correct-managed
Plottable
📊 A library of modular chart components built on D3
Stars: ✭ 2,834 (+20142.86%)
Mutual labels:  octo-correct-managed
hadoop-crypto
Library for per-file client-side encyption in Hadoop FileSystems such as HDFS or S3.
Stars: ✭ 38 (+171.43%)
Mutual labels:  octo-correct-managed
dropwizard-web-security
A Dropwizard bundle for applying default web security functionality
Stars: ✭ 37 (+164.29%)
Mutual labels:  octo-correct-managed
gradle-consistent-versions
Compact, constraint-friendly lockfiles for your dependencies
Stars: ✭ 92 (+557.14%)
Mutual labels:  octo-correct-managed
metric-schema
Schema for standard metric definitions
Stars: ✭ 13 (-7.14%)
Mutual labels:  octo-correct-managed
goastwriter
Go library for writing Go source code programatically
Stars: ✭ 27 (+92.86%)
Mutual labels:  octo-correct-managed
giraffe
Gracefully Integrated Remote Access For Files and Execution
Stars: ✭ 50 (+257.14%)
Mutual labels:  octo-correct-managed

Dropwizard Web Logger

Circle CI Download

WebLoggerBundle is a Dropwizard bundle used to help log web activity to log files on a server's backend.

###Example 1: Log Event

####Make Call Send a POST request to:

http://localhost:8000/<web-app-name>/api/web-logger/events/<eventName>

Example

http://localhost:8000/<web-app-name>/api/web-logger/events/jump

with the body content:

{"height":"42feet","name":"douglas"}

and the following configuration:

webLoggerEnabled: true

####A Line is Logged Logger will log the following line to a file on a specific backend

{"name":"douglas","eventName":"jump","height":"42feet","timestamp":"2016-03-07 10:41:38 UTC"}

###Example 2: Log Batch of Events

Send a POST request to:

http://localhost:8000/<web-app-name>/api/web-logger/events/batch

Example

http://localhost:8000/<web-app-name>/api/web-logger/events/batch

with the body content:

{"jump": {"height":"42feet","name":"douglas"}, "crawl": {"height":"45feet","name":"robert"}}

and the following configuration:

webLoggerEnabled: true

####The Lines are Logged Logger will log the following lines to a file on a specific backend

{"name":"douglas","eventName":"jump","height":"42feet","timestamp":"2016-03-07 10:41:38 UTC"}
{"name":"robert","eventName":"crawl","height":"45feet","timestamp":"2016-03-07 10:41:40 UTC"}

###Fixed Fields Fixed fields will be added to all logged lines.

Type Description
Timestamp The timestamp of the log will be logged as yyyy-MM-dd HH:mm:ss z in UTC

Usage

  1. Add the com.palantir.weblogger:dropwizard-web-logger:<VERSION> dependency to your project's build.gradle file. The most recent version number can be found by looking at the Releases Page. The dependencies section should look something like this:

    dependencies {
    	// ... unrelated dependencies omitted ...
    	compile "com.palantir.weblogger:dropwizard-web-logger:<VERSION>"
    }
    
  2. Modify your server's configuration file

    a. Add webLoggerEnabled to your yml file and enable it. server.yml

        webLoggerEnabled: true
    

    b. Add an appender of type web-logger to your Dropwizard configuration YAML in the logging section: server.yml

          - type: web-logger
            currentLogFilename: ./var/log/<APPNAME>-usage.json.log
            archivedLogFilenamePattern: ./var/log/<APPNAME>-usage-%d.json.log
            archivedFileCount: <NUMBER_OF_LOGFILES_TO_ARCHIVE>
    

    Example

        logging:
          appenders:
            - type: file
              currentLogFilename: var/log/server.log
              archivedLogFilenamePattern: var/log/server-%d.log
              archivedFileCount: 5
              timeZone: UTC
              threshold: INFO
            - type: console
              threshold: INFO
            - type: web-logger
              currentLogFilename: ./var/log/fe-logger-usage.json.log
              archivedLogFilenamePattern: ./var/log/fe-logger-usage-%d.json.log
              archivedFileCount: 5
    
  3. Have your configuration implement WebLoggerConfigurable:

    public final class ExampleApplicationConfiguration extends Configuration
            implements WebLoggerConfigurable {
    
        private final boolean webLoggerEnabled;
    
        @JsonCreator
        public ExampleApplicationConfiguration(
            @JsonProperty("webLoggerEnabled") boolean webLoggerEnabled) {
    
            this.webLoggerEnabled = webLoggerEnabled;
        }
    
        @Override
        public boolean isWebLoggerEnabled() {
            return this.webLoggerEnabled;
        }
    }
  4. Add the bundle to your Dropwizard application.

        @Override
        public void initialize(Bootstrap<ExampleApplicationConfiguration> bootstrap) {
            bootstrap.addBundle(new WebLoggerBundle());
        }

Setting up the project with an IDE

with Eclipse, import the project and run:

    ./gradlew eclipse

with IntelliJ, import the project and run:

    ./gradlew idea

Authentication and Security

While it is possible to use this bundle without requiring user authentication or handling possible XSRF (cross-site request forgery) issues, the data collected by the event logger would likely not be useful.

It is strongly recommended that this bundle be used together with authentication and XSRF prevention.

Contributing

Before working on the code, if you plan to contribute changes, please read the CONTRIBUTING document.

License

This project is made available under the Apache 2.0 License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].