logback-logdna

Log back appender for LogDNA

License

License

MIT
Categories

Categories

Logback Application Layer Libs Logging
GroupId

GroupId

com.github.imdurgadas
ArtifactId

ArtifactId

logback-logdna
Last Version

Last Version

1.1
Release Date

Release Date

Type

Type

jar
Description

Description

logback-logdna
Log back appender for LogDNA
Project URL

Project URL

https://github.com/imdurgadas/logback-logdna
Source Code Management

Source Code Management

https://github.com/imdurgadas/logback-logdna

Download logback-logdna

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.imdurgadas/logback-logdna/ -->
<dependency>
    <groupId>com.github.imdurgadas</groupId>
    <artifactId>logback-logdna</artifactId>
    <version>1.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.imdurgadas/logback-logdna/
implementation 'com.github.imdurgadas:logback-logdna:1.1'
// https://jarcasting.com/artifacts/com.github.imdurgadas/logback-logdna/
implementation ("com.github.imdurgadas:logback-logdna:1.1")
'com.github.imdurgadas:logback-logdna:jar:1.1'
<dependency org="com.github.imdurgadas" name="logback-logdna" rev="1.1">
  <artifact name="logback-logdna" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.imdurgadas', module='logback-logdna', version='1.1')
)
libraryDependencies += "com.github.imdurgadas" % "logback-logdna" % "1.1"
[com.github.imdurgadas/logback-logdna "1.1"]

Dependencies

compile (4)

Group / Artifact Type Version
ch.qos.logback : logback-classic jar 1.2.3
org.projectlombok : lombok jar 1.18.10
com.squareup.okhttp3 : okhttp jar 3.4.2
org.json : json jar 20190722

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

Logback appended for LogDNA Build Status

LogDNA is a hosted logging platform: https://logdna.com. This library provides an asynchronous appender for logback, allowing to send your logs to the LogDNA platform (LogDNA + LogDNA service provided by Cloud providers). Library also allows you to send stacktrace such that it's visible in one go rather than different lines. In addition , it supports Mapped Diagnostic Context(MDC) too where you can pass additional metadata seamlessly and the same can be used to filter logs on the LogDNA dashboard.

How To Use it

Add this dependency to your pom.xml

<dependency>
  <groupId>com.github.imdurgadas</groupId>
  <artifactId>logback-logdna</artifactId>
  <version>1.1</version>
</dependency>

Logback uses XML file in known locations with the most common being classpath:/logback.xml | src/main/resources/logback.xml

Copy the content to your logback.xml:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <appender name="logDNA-http" class="com.github.imdurgadas.appender.LogDNAAppender">
    <appName>LogDNA-Logback-Aoo</appName>
    <includeStacktrace>true</includeStacktrace>
    <ingestKey>${INGESTION_KEY}</ingestKey>
    <logDnaUrl>${LOGDNA_URL}</logDnaUrl>
  </appender>

  <appender name="logDNA" class="ch.qos.logback.classic.AsyncAppender">
    <appender-ref ref="logDNA-http"/>
  </appender>


  <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
      <charset>utf8</charset>
      <pattern>%-30(%d{HH:mm:ss.SSS} [%thread]) %-5level %m%n</pattern>
    </encoder>
  </appender>

  <root level="DEBUG">
    <appender-ref ref="console"/>
    <appender-ref ref="logDNA"/>
  </root>
</configuration>

Configuration

  • Set up your INGESTION_KEY (api key) via environment variables.
  • Set up the LOGDNA_URL (api url) the same way. https://logs.logdna.com/logs/ingest https://logs.us-south.logging.cloud.ibm.com/logs/ingest
  • You can toggle including stacktrace using the <includeStacktrace>true</includeStacktrace> to either true or false
  • Passing MDC as easy as MDC.put(key,value).
    You can view the data on LogDNA dashboard by using the following format: meta.{keyname}:"value"

Versions

Version
1.1
1.0