otj-logging-redis

Logging component Redis appender

Categories

Categories

Redis Data Databases Logging Application Layer Libs
GroupId

GroupId

com.opentable.components
ArtifactId

ArtifactId

otj-logging-redis
Last Version

Last Version

2.2.1
Release Date

Release Date

Type

Type

jar
Description

Description

otj-logging-redis
Logging component Redis appender

Download otj-logging-redis

How to add to project

<!-- https://jarcasting.com/artifacts/com.opentable.components/otj-logging-redis/ -->
<dependency>
    <groupId>com.opentable.components</groupId>
    <artifactId>otj-logging-redis</artifactId>
    <version>2.2.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.opentable.components/otj-logging-redis/
implementation 'com.opentable.components:otj-logging-redis:2.2.1'
// https://jarcasting.com/artifacts/com.opentable.components/otj-logging-redis/
implementation ("com.opentable.components:otj-logging-redis:2.2.1")
'com.opentable.components:otj-logging-redis:jar:2.2.1'
<dependency org="com.opentable.components" name="otj-logging-redis" rev="2.2.1">
  <artifact name="otj-logging-redis" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.opentable.components', module='otj-logging-redis', version='2.2.1')
)
libraryDependencies += "com.opentable.components" % "otj-logging-redis" % "2.2.1"
[com.opentable.components/otj-logging-redis "2.2.1"]

Dependencies

compile (7)

Group / Artifact Type Version
com.opentable.components : otj-logging jar 2.1.1
ch.qos.logback : logback-core jar 1.1.7
ch.qos.logback : logback-classic jar 1.1.7
com.google.guava : guava jar 20.0
com.fasterxml.jackson.core : jackson-databind jar 2.8.5
redis.clients : jedis jar 2.5.1
org.apache.commons : commons-pool2 jar

runtime (1)

Group / Artifact Type Version
org.slf4j : jcl-over-slf4j jar 1.7.21

test (5)

Group / Artifact Type Version
junit : junit jar 4.12
org.hamcrest : hamcrest-core jar 1.3
com.fasterxml.jackson.module : jackson-module-mrbean jar 2.8.5
com.github.spullara.redis : netty4-server jar 0.7-OT-2
io.netty : netty-all jar 4.0.10.Final

Project Modules

There are no modules declared in this project.

OpenTable Logging Components

Build Status

Component Charter

  • Manage Logback configuration and integration with other logging APIs.
  • Provide reference implementation of the standard logging format
  • Provide Appender implementations for OpenTable logging infrastructure
  • Allow logging structured data in addition to traditional String messages

otj-logging-core

The Core module provides definitions for the OpenTable common log format.

The CommonLogFields interface defines the fields that are sent for all logging events. The HttpLogFields interface defines the fields that are sent for HTTP access log events. The ApplicationLogEvent class wraps a Logback logging event and exposes the common log format.

It also provides a Logback encoder JsonLogEncoder which serializes the above event types into a format suitable to submit to the OpenTable logging infrastructure through an arbitrary Appender.

The common log format defines a "servicetype" field which should be filled with the name of the service. As the logger does not know the name of the service it is running in, this must be provided by the application. For applications using our template, the otj-server component takes care to set this correctly. ther applications should explicitly initialize this early on during application initialization:

CommonLogHolder.setServiceType("my-cool-server");

otj-logging-redis

  • This component was removed in 2017. All logging on OTJ platform now occurs via Kafka.

otj-logging-kafka

The Kafka module provides an Appender that submits logging events to a Kafka queue. Example configuration:

<?xml version="1.0" encoding="UTF-8" ?>

<!--
  Example configuration that logs text to the console and JSON to Kafka
-->
<configuration threshold="TRACE">
  <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
      <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
    </encoder>
  </appender>

  <appender name="KAFKA" class="com.opentable.logging.KafkaAppender">
    <encoder class="com.opentable.logging.JsonLogEncoder"/>
    <brokerList>localhost:12345</brokerList>
    <topic>logs</topic>
    <clientId>my-application-name</clientId>
  </appender>

  <!-- Default is DEBUG for our stuff, INFO for everything else -->
  <logger name="com.opentable" level="DEBUG" />

  <root level="INFO">
    <appender-ref ref="CONSOLE" />
    <appender-ref ref="KAFKA" />
  </root>
</configuration>

otj-logging-bucket

Perhaps you need to rate limit or sample your logging? We've got a module for you.

Import otj-logging-bucket as a dependency and use either of these implementations as a decorator for your SLF4J Logger.

  • BucketLog - Uses a token bucket to rate limit. There are several static methods you can use. Here's an example
    private static final Logger LOG = BucketLog.of(MyClass.class, 10); // 10 per second
  • SamplingLog - Does a coin flip. You provide a number between 0 and 1 representing probability. Providing .1 for example means there's about a 10% rate of logging.
    private static final Logger LOG = SamplngLog.of(MyClass.class, .1); // 10% logged

otj-logging

The main module ties together all of the above modules. In addition, it provides adapters to pull together other common logging frameworks:

  • java.util.logging via jul-to-slf4j
  • commons-logging via jcl-over-slf4j
  • log4j via log4j-over-slf4j

Usually you will not need to use this artifact directly, it is used by otj-server.


Copyright (C) 2016 OpenTable, Inc.

com.opentable.components

OpenTable

Restaurant Reservations

Versions

Version
2.2.1
2.2.0
2.1.1
2.0.2
2.0.1
2.0.0
1.10.1
1.10.0
1.9.1
1.9.0
1.8.0
1.7.0
1.6.5
1.6.4
1.6.3
1.6.2
1.6.1
1.6.0
1.5.0
1.4.2
1.4.1
1.4.0