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

Fix the issue of slf4j isolation #1745

Open
renyingxin opened this issue Feb 11, 2025 · 0 comments
Open

Fix the issue of slf4j isolation #1745

renyingxin opened this issue Feb 11, 2025 · 0 comments
Labels
kind/bug Something isn't working

Comments

@renyingxin
Copy link

What happened?

logger problems occurs when use slf4j for logging in Sermant
1、slf4j 1.7.x and below use classloader to find binds of StaticLoggerBinder
2、slf4j 1.8.x and above use SPI to find SLF4JServiceProvider

both FrameworkClassLoader and PluginClassLoader should be fixed, we use PluginClassLoader to illustrate the problem
case1(Plugin use slf4j 1.7.x-): getResources will find StaticLoggerBinder bindings both in the plugin and in the host application, and the order is undefined due to the slf4j doc, so may cause plugin can not log correctly
case2(Plugin use slf4j 1.8.x+): getResources will find SLF4JServiceProvider implementations both in the plugin and in the host application, this will cause load of related classes in host application, and may cause problems
(due to privacy issue we can not post related info, but the problem is as descirbed)

How can we reproduce it (as minimally and precisely as possible)?

This problem is already known to Sermant, and in 2.X is almost fixed. (getResources)
https://github.com/sermant-io/Sermant/blob/2.2.x/sermant-agentcore/sermant-agentcore-core/src/main/java/io/sermant/core/classloader/FrameworkClassLoader.java

We expect:
Seramnt 1.x: Both FrameworkClassLoader and PluginClassLoader should be fixed as above
Sermant 2.x: PluginClassLoader missed process of StaticLoggerBinder, and should be fixed

Anything else we need to know?

We already upload the patch code to the enviroment, and found the solution works.

Sermant version

Sermant 1.2.0-1.4.1

OS version

# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here

# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here
@renyingxin renyingxin added the kind/bug Something isn't working label Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant