opentelemetry-java-examples icon indicating copy to clipboard operation
opentelemetry-java-examples copied to clipboard

Example of Log Appenders when using OpenTelemetry JavaAgent

Open smoke opened this issue 1 year ago • 2 comments

smoke avatar Oct 10 '24 09:10 smoke

Such example was useful for me to explore how the log appending works when using JavaAgent and how to properly configure them. I was under the impression logger xml files can be used to configure them accordingly, but this is not the case.

My final goal was to achieve ability to control from properties and env vars the Logs Sending and Level. There is my PoC implementation https://github.com/smoke/opentelemetry-java-examples/pull/1 that allows usage of these env vars or system properties defined in log4j2.xml:

  • LOG_LEVEL env var or logLevel property - controls the log4j2 Root (and inherited) loggers level
  • OTEL_X_LOG_SENDING_DISABLED env var or otel.x.log_sending.disabled property - set to "true" to fully disable the OpenTelemetryAppender
  • OTEL_X_LOG_SENDING_LEVEL env var or otel.x.log_sending.level property - defaults to "all", set to relevant log4j2 Level (off, fatal, error, warn, info, debug, trace, all) to additionally filter what goes to Otel Collector

smoke avatar Oct 11 '24 07:10 smoke

@jeanbisutti Thanks for your review! I have made changes to address your remarks, please re-review.

smoke avatar Oct 17 '24 11:10 smoke