<commit_before># StructLog4J

Structured logging Java, on top of the SLF4J API.
Designed to generate easily parsable log messages for consumption in services such as LogStash, Splunk, ElasticSearch, etc.

## Adding to your project

The artifacts for this library are published to the popular Bintray JCenter Maven repository.

### Gradle

    repositories {
        jcenter()
    }

    compile 'structlog4j:structlog4j-api:0.2.0'

### Maven

    <repositories>
      <repository>
        <id>jcenter</id>
          <url>http://jcenter.bintray.com</url>
      </repository>
    </repositories>

    <dependency>
      <groupId>structlog4j</groupId>
      <artifactId>structlog4j-api</artifactId>
      <version>0.2.0</version>
      <type>pom</type>
    </dependency>

# Overview

Standard Java messages look something like this

    Handled 4 events while processing the import batch processing

This is human readable, but very difficult to parse by code in a log aggregation serivce, as every developer can enter any free form text they want, in any format.

Instead, we can generated a message like this

    Handled events service="Import Batch" numberOfEvents=4

This is very easy to parse, the message itself is just a plain description and all the context information is
passed as separate key/value pairs (or in the future JSON, YAML, etc)

# Usage

StructLog4J is implemented itself on top of the SLF4J API. Therefore any application that already uses SLF4J can
start using it immediately as it requires no other changes to existing logging configuration.

Instead of the standard SLF4J Logger, you must instantiate instead the StructLog4J Logger:

    private ILogger log = SLoggerFactory.getLogger(MyClass.class);

The **ILogger** interface is very simple and offers just these basic methods:<commit_msg>fixed up docs<commit_after># StructLog4J

Structured logging Java, on top of the SLF4J API.
Designed to generate easily parsable log messages for consumption in services such as LogStash, Splunk, ElasticSearch, etc.

## Adding to your project

The artifacts for this library are published to the popular Bintray JCenter Maven repository.

### Gradle

    repositories {
        jcenter()
    }

    compile 'structlog4j:structlog4j-api:0.2.0'

### Maven

    <repositories>
      <repository>
        <id>jcenter</id>
          <url>http://jcenter.bintray.com</url>
      </repository>
    </repositories>

    <dependency>
      <groupId>structlog4j</groupId>
      <artifactId>structlog4j-api</artifactId>
      <version>0.2.0</version>
      <type>pom</type>
    </dependency>

# Overview

Standard Java messages look something like this

    Handled 4 events while processing the import batch processing

This is human readable, but very difficult to parse by code in a log aggregation serivce, as every developer can enter any free form text they want, in any format.

Instead, we can generate a message like this

    Handled events service="Import Batch" numberOfEvents=4

This is very easy to parse, the message itself is just a plain description and all the context information is
passed as separate key/value pairs (or in the future JSON, YAML, etc)

# Usage

StructLog4J is implemented itself on top of the SLF4J API. Therefore any application that already uses SLF4J can
start using it immediately as it requires no other changes to existing logging configuration.

Instead of the standard SLF4J Logger, you must instantiate the StructLog4J Logger:

    private ILogger log = SLoggerFactory.getLogger(MyClass.class);

The **ILogger** interface is very simple and offers just these basic methods:
{'fraction_non_alphanumeric': 0.06348330113165884, 'fraction_numerical': 0.010488545404361027, 'mean_word_length': 3.806366047745358, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1475178', 'n_tokens_mistral': 1039, 'n_tokens_neox': 975, 'n_words': 436}