[Enhancement] Log printing failure problem in agent mode #1513
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1428
At present, java prints logs mostly with slf4j and log4j/logback, but agent is a separate jar package.
To use slf4j, you need to introduce the package into agent, which may conflict with the business's own slf4j logback log.
And after the agent package uses the slf4j-api package, you need to ensure that the classLoader of the agent is consistent with the classLoader of the business, otherwise conflicts cannot be found or repeated.
How to remove conflict
In tomcat
The internal logging for Apache Tomcat uses JULI, a packaged renamed fork of Apache Commons Logging that is hard-coded to use the java.util.logging framework. This ensures that Tomcat's internal logging and any web application logging will remain independent, even if a web application uses Apache Commons Logging.
Reference: https://tomcat.apache.org/tomcat-9.0-doc/logging.html
In pinpoint and skywalking
Pinoint and skywalking create custom Logger class. They use sender class to transfer trace and metric to collector server.
Reference:
Solution
There is a Skywalking-like ILOG component in the agent-core package, which removes the ILog component from the existing agent-core package into the infra common package, so that other Agent modules can directly use the custom log component without relying on Slf4j to print the log, avoiding the problem of log non-printing.
Successfully solved: