An open API service indexing awesome lists of open source software.

https://github.com/michaljonko/dynatrace-log4j2-appender

Dynatrace Generic Log Ingest Log4j2 Appender
https://github.com/michaljonko/dynatrace-log4j2-appender

dynatrace dynatrace-log4j2-appender log4j2 opentelemetry-instrumentation

Last synced: 6 months ago
JSON representation

Dynatrace Generic Log Ingest Log4j2 Appender

Awesome Lists containing this project

README

          

![Dynatrace Generic Log Ingest Log4j2 Appender](icon.png)
# Dynatrace Generic Log Ingest Log4j2 Appender
Log4j2 Appender & Lookup to integrate Java applications with _Dynatrace Generic Log Ingest_ functionality.

Last stable version: _0.0.8_

To make it works you have to provide two parameters:
- `activeGateUrl` - URL to ActiveGate instance with Generic Log Ingest module enabled
- `token` - valid token with _Log Import_ permission enabled
- `sslValidation` - SSL certificate has to be valid. _false_ value will pass self-signed certificates. (OPTIONAL)

_DynatraceLookup_ is used to lookup entity attributes used internally by the Dynatrace.
Attributes can be accessed with prefix `${dt:}` in the configuration.

Lookup attribute | Configuration | Description
--- | --- | ---
`dt.entity.process_group_instance` | ${dynatrace:dt.entity.process_group_instance} | Process Group Instance of application running appender
`dt.entity.host` | ${dynatrace:dt.entity.host} | Host running application

_OpenTelemetryLookup_ is used to lookup thread-local contextual information delivered by OpenTelemetry Instrumentation for Java.
Attributes can be accessed with prefix `${otel:}` in the configuration.

Lookup attribute | Configuration | Description
--- | --- | ---
`trace_id` | ${otel:trace_id} | The current trace id
`span_id` | ${otel:span_id} | The current span id
`trace_flags` | ${otel:trace_flags} | The current trace flags, formatted according to W3C traceflags format

### Requirements
- **Log4j2** version >= 2.25.3
- for _DynatraceLookup_ ** [Dynatrace OneAgent](https://www.dynatrace.com/support/help/dynatrace-api/environment-api/deployment/oneagent/download-oneagent-latest/) ** 1.215 and newer is needed
- for _OpenTelemetryLookup_ ** [OpenTelemetry Instrumentation for Java](https://github.com/open-telemetry/opentelemetry-java-instrumentation) ** is needed

### How to use it:
Gradle
```groovy
repositories {
mavenCentral()
}

dependencies {
compileOnly group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.25.3'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.25.3'

runtimeOnly group: 'io.github.michaljonko', name: 'dynatrace-log4j2-appender', version: '0.0.8'
runtimeOnly group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.25.3'
}
```
Maven
```xml

io.github.michaljonko
dynatrace-log4j2-appender
0.0.8
pom

```

### Examples
Simple configuration with defined layout for a message (will be shown as content in Dynatrace Log Viewer):
```xml














```

Simple configuration with three additional attributes (will be part of the log) and custom layout for a message:
```xml



Log4j2 Appender Tester
${java:os}
${sys:user.dir}/debug.log







```

Simple configuration with three additional attributes, lookup attributes from _DynatraceLookup_ and custom layout for a message:
```xml



Log4j2 Appender Tester
${java:os}
${sys:user.dir}/debug.log
${dt:dt.entity.process_group_instance}
${dt:dt.entity.host}







```

Simple configuration with three additional attributes, lookup attribute from _DynatraceLookup_, lookup attribute from _OpenTelemetryLookup_ and custom layout for a message:
```xml



Log4j2 Appender Tester
${java:os}
${sys:user.dir}/debug.log
${dt:dt.entity.process_group_instance}
${otel:trace_id}







```