-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OpenTelemetryAppender with Pax Log #556
Comments
Hello!
pax-logging-log4j2 is configuring Log4j2 Logging Manager using all its discovery mechanism, which include plugin discovery. https://github.com/ops4j/org.ops4j.pax.logging/tree/main/pax-logging-samples/fragment-log4j2 is an example plugin that adds new appender called @Plugin(name = "List", category = Core.CATEGORY_NAME, elementType = Appender.ELEMENT_TYPE)
public class ListAppender extends AbstractAppender { which is then declared in In order for pax-logging-log4j2 to see this descriptor, the Because https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/log4j/log4j-appender-2.17/library/build.gradle.kts it's a Gradle-based build, I can't easily check what is the result of such build... I checked https://repo1.maven.org/maven2/io/opentelemetry/instrumentation/opentelemetry-log4j-appender-2.17/2.10.0-alpha/ and it contains proper (at first glance)
For now I can't give you more than the above context, because I really can't afford doing it myself now ;) sorry... |
I agree with @grgrzybek : adding the appender (using fragment) should work. You have an example here: https://github.com/apache/karaf/tree/main/examples/karaf-log-appender-example For context, you also have Apache Karaf Decanter that can log to get log messages sent to prometheus for instance. |
Thank for hints but maybe I wasn't clear enough. This appender is part of opentelemetry-javaagent.jar. So I don't know how to create osgi fragment for this because this jar is outside karaf (I setup it via setenv JAVA_OPTS") and it is not a karaf bundle. |
In special branch https://github.com/ops4j/org.ops4j.pax.logging/commits/example-556/ I created a sample Maven module with a fragment that embeds The config produces a fragment with this
Them on fresh Karaf 4.4.6: I installed this fragment:
Refreshed the host:
And immediately in the console (because when you refresh logging implementation, you can't use it to log information ;) - so only basic debug logging from pax-logging-api (fallback logging) was used) I saw:
It simply means that embedding just: <dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-log4j-appender-2.17</artifactId>
</dependency> is not sufficient... From my experience I know that sometimes these big projects or projects that simply ship tens of different artifacts under the same group ID and version, are not easy - you can't quickly tell which dependencies are needed. Using
I found that I have to embed 8 JARs in total, but it allowed me to refresh the pax-logging-log4j2 bundle correctly:
The configuration I used in
Under the debugger I saw proper appender attached to my logger:
That's all I can do for now - I hope this'll help you check how it works, because I'm not (yet?) very familiar with Open Telemetry (I know there has to be some event collector available?) |
Thank a lot, I will check it. |
I use Opentelemetry Java agent with Karaf. It works but now I would like to receive all logs from karaf (4.4.6). I'm able to receive only opentelemetry internal logs but not logs from my application or karaf itself.
I have checked examples but it seems to me that this is a little bit different case as in examples.
Part of opentelemetry java agent is also Log4j2 appender
https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/log4j/log4j-appender-2.17/library/src/main/java/io/opentelemetry/instrumentation/log4j/appender/v2_17/OpenTelemetryAppender.java
log4j2 can be configured something like this:
But I don't have any idea how to export OpenTelemetryAppender to pax log so that log4j2 would be able to register a new type of appender.
So in general, could you advise me if it is even possible (there are some "special" things that javagent does). And if it is possible can you give me some hints (examples,blog) what I have to do.
The text was updated successfully, but these errors were encountered: