hippo4j icon indicating copy to clipboard operation
hippo4j copied to clipboard

[Enhancement] Log printing failure problem in agent mode

Open Pan-YuJie opened this issue 1 year ago • 1 comments

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:

  • pinpoint BootLogger (https://github.com/pinpoint-apm/pinpoint)](https://github.com/pinpoint-apm/pinpoint)
  • skywalking ILog (https://github.com/apache/skywalking)](https://github.com/apache/skywalking)

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:

image-20231112232442138


Pan-YuJie avatar Nov 12 '23 16:11 Pan-YuJie

Codecov Report

Attention: 245 lines in your changes are missing coverage. Please review.

Comparison is base (bb6dbc7) 34.23% compared to head (3ca8b29) 30.66%. Report is 2 commits behind head on develop.

:exclamation: Current head 3ca8b29 differs from pull request most recent head 59e89ef. Consider uploading reports for the commit 59e89ef to get more accurate results

Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #1513      +/-   ##
=============================================
- Coverage      34.23%   30.66%   -3.58%     
  Complexity       847      847              
=============================================
  Files            262      298      +36     
  Lines           5953     6647     +694     
  Branches         560      646      +86     
=============================================
  Hits            2038     2038              
- Misses          3722     4416     +694     
  Partials         193      193              
Files Coverage Δ
...o4j/common/boot/AgentPackageNotFoundException.java 0.00% <ø> (ø)
...in/java/cn/hippo4j/common/boot/ClassCacheMode.java 0.00% <ø> (ø)
...hippo4j/common/boot/DefaultNamedThreadFactory.java 0.00% <ø> (ø)
...n/src/main/java/cn/hippo4j/common/conf/Config.java 0.00% <ø> (ø)
...n/hippo4j/common/conf/ConfigNotFoundException.java 0.00% <ø> (ø)
...ppo4j/common/conf/RuntimeContextConfiguration.java 0.00% <ø> (ø)
...java/cn/hippo4j/common/logging/api/LogManager.java 0.00% <ø> (ø)
...java/cn/hippo4j/common/logging/api/NoopLogger.java 0.00% <ø> (ø)
...cn/hippo4j/common/logging/core/AbstractLogger.java 0.00% <ø> (ø)
...ava/cn/hippo4j/common/logging/core/FileWriter.java 0.00% <ø> (ø)
... and 27 more

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Nov 12 '23 16:11 codecov[bot]