otj-logging-core

Logging component core

Categories

Categories

Logging Application Layer Libs
GroupId

GroupId

com.opentable.components
ArtifactId

ArtifactId

otj-logging-core
Last Version

Last Version

1.10.1
Release Date

Release Date

Type

Type

jar
Description

Description

otj-logging-core
Logging component core

Download otj-logging-core

How to add to project

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

Dependencies

compile (8)

Group / Artifact Type Version
com.opentable.components : otj-serverinfo jar 1.6.0
ch.qos.logback : logback-core jar 1.1.3
ch.qos.logback : logback-classic jar 1.1.3
org.slf4j : slf4j-api jar 1.7.12
com.fasterxml.jackson.core : jackson-annotations jar 2.4.6
com.fasterxml.jackson.core : jackson-core jar 2.4.6
com.fasterxml.jackson.core : jackson-databind jar 2.4.6
com.fasterxml.jackson.datatype : jackson-datatype-jsr310 jar 2.4.6

test (6)

Group / Artifact Type Version
com.fasterxml.jackson.module : jackson-module-mrbean jar 2.4.6
junit : junit jar 4.12
org.hamcrest : hamcrest-core jar 1.3
org.hamcrest : hamcrest-library jar 1.3
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
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