如何沙箱 SLF4J
我有一个应用程序(扩展)在 Smartfox 服务器内运行。大多数人都不知道 Smartfox,但其设置与 Tomcat 类似。即扩展有自己的类加载器,它首先从扩展加载类,然后加载全局服务器库(我将其称为“自私类加载”,因为我不知道官方术语(如果有的话)。
我有多个 SLF4J 绑定问题,我的扩展包含 logback,服务器包含另一个 slf4j 绑定(这对我来说没用):
INFO | jvm 1 | 2011/10/06 11:10:25 | SLF4J: Class path contains multiple SLF4J bindings.
INFO | jvm 1 | 2011/10/06 11:10:25 | SLF4J: Found binding in [jar:file:/opt/smartfox/Server/lib/lsc.jar!/org/slf4j/impl/StaticLoggerBinder.class]
INFO | jvm 1 | 2011/10/06 11:10:25 | SLF4J: Found binding in [jar:file:/opt/smartfox/Server/wext/smilefish/logback-classic-jar-logback-classic-0.9.29.jar!/org/slf4j/impl/StaticLoggerBinder.class]
我希望自私的类加载能够解决此类问题,但显然没有。如何在不删除任何绑定的情况下解决此问题?
(参见 是否有一个类似 Tomcat 的类加载器可以独立使用吗? 获取自私类加载器的源代码)
I have a an application (extension) running inside a Smartfox server. Most of you won't know Smartfox, but the setup is like Tomcat. i.e. the extension has its own classloader which loads classes from the extension first, the global server libs after (I will call this selfish classloading, since I don't know the official term, if any exists).
I have a multiple SLF4J bindings problem, with my extension containing logback and the server containing another slf4j binding (that is useless to me):
INFO | jvm 1 | 2011/10/06 11:10:25 | SLF4J: Class path contains multiple SLF4J bindings.
INFO | jvm 1 | 2011/10/06 11:10:25 | SLF4J: Found binding in [jar:file:/opt/smartfox/Server/lib/lsc.jar!/org/slf4j/impl/StaticLoggerBinder.class]
INFO | jvm 1 | 2011/10/06 11:10:25 | SLF4J: Found binding in [jar:file:/opt/smartfox/Server/wext/smilefish/logback-classic-jar-logback-classic-0.9.29.jar!/org/slf4j/impl/StaticLoggerBinder.class]
I was hoping that the selfish classloading would fix this kind of problem, but apparently it doesn't. How can I fix this without removing either binding?
(See Is there a Tomcat-like classloader that can be used standalone? for the source code of the selfish classloader)
SLF4J 发出的输出只是一个警告。从您描述的类加载(自私/叶子优先/本地优先)来看,SLF4J 可能与 logback 绑定。你检查了吗?
The output emitted by SLF4J is just a warning. From the class loading you describe (selfish/leaf-first/local-first), SLF4J has probably bound with logback. Did you check?