Skip to content
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

Logging agent logs separately #7179

Closed
maverick-devil opened this issue Nov 15, 2022 · 11 comments · Fixed by #7339
Closed

Logging agent logs separately #7179

maverick-devil opened this issue Nov 15, 2022 · 11 comments · Fixed by #7339

Comments

@maverick-devil
Copy link

Currently opentelemetry agent logs in the application logs itself. This pollutes the application logs, and also if there are any errors, they spam the application logs.
Currently agent uses slf4j simple to log these logs.
Can the logs be moved to a log file? It would be a cleaner approach. I would like to know if above approach was done due to some issues faced.
I'm thinking if we can add slf4j-api with logback. Let me know what can be the complications involved if I do so.

@maverick-devil
Copy link
Author

Hello! Can I get any response please!

@laurit
Copy link
Contributor

laurit commented Nov 21, 2022

You should be able to redirect agent logs to file with -Dio.opentelemetry.javaagent.slf4j.simpleLogger.logFile=path-to-log-file

@maverick-devil
Copy link
Author

Thanks for the info. But as I see, agent uses a simple logger, and does not have rolling policy. Some times, in case otel collector goes down, logs would pile up in single application file. Are there any plans to make changes to simple logger? Would like to know and contribute if there are any such plans. Thanks!

@mateuszrzeszutek
Copy link
Member

Are there any plans to make changes to simple logger? Would like to know and contribute if there are any such plans. Thanks!

This topic has come up multiple times (#3413, #7257, #5059 and more) - I'm planning to clear up some time and prepare a POC of #5059, this should resolve your issue too.

@michaeltcoelho
Copy link

Hey folks!

Is it possible to, when working with logback in spring, specify somehow via property -Dio.opentelemetry.javaagent.slf4j.*** to route logs messages to a specific Appender? Considering I have an appender which formats my log in JSON. If I do not turn the agent's logging off like -Dio.opentelemetry.javaagent.slf4j.simpleLogger.defaultLogLevel=off" my logs parser fails as it gets the log texts from the javaagent.

@mateuszrzeszutek
Copy link
Member

Hey @michaeltcoelho ,
Right now it is not possible to redirect agent logs into application logging system. Once #7339 is merged (and probably a couple follow-up PRs as well) it will become an option.

@apanasevich
Copy link

apanasevich commented Dec 22, 2022

You should be able to redirect agent logs to file with -Dio.opentelemetry.javaagent.slf4j.simpleLogger.logFile=path-to-log-file

It works perfect if specified as JVM argument. Is it possible to specify this property in an javaagent configuration file?
I have tried but with no result, javaagent started to write its logs to stderr back.

UPD: Looks like only system properties is the way to configure at the moment
https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/javaagent-internal-logging-simple/src/main/java/io/opentelemetry/javaagent/logging/simple/Slf4jSimpleLoggingCustomizer.java

@mateuszrzeszutek
Copy link
Member

Is it possible to specify this property in an javaagent configuration file?
I have tried but with no result, javaagent started to write its logs to stderr back.

Nope - the reason for that is that logging is initialized as one of the first javaagent subsystems, way before full configuration is assembled.

@lgext06
Copy link

lgext06 commented Mar 23, 2023

Hi @mateuszrzeszutek ,
any news about your pending changes?

@mateuszrzeszutek
Copy link
Member

Hey @lgext06 ,
Still pending -- I'll ping all the parties involved and try to get it merged before the next release.

@hajekt2
Copy link

hajekt2 commented Feb 6, 2024

Is it possible to, when working with logback in spring, specify somehow via property -Dio.opentelemetry.javaagent.slf4j.*** to route logs messages to a specific Appender? Considering I have an appender which formats my log in JSON. If I do not turn the agent's logging off like -Dio.opentelemetry.javaagent.slf4j.simpleLogger.defaultLogLevel=off" my logs parser fails as it gets the log texts from the javaagent.
Hi @michaeltcoelho, I am dealing with the same issue, logs in text format, but I need JSON formated instead. Have you found the solution on that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants